How can PHP developers ensure seamless session management for users with disabled cookies?

When users have disabled cookies, PHP developers can use URL rewriting to pass session IDs between pages. By appending the session ID to the URL, developers can ensure seamless session management for users without relying on cookies.

// Start or resume session
session_start();

// Check if session ID is passed in the URL
if(isset($_GET['PHPSESSID'])) {
    session_id($_GET['PHPSESSID']);
}

// Use session variables as needed
$_SESSION['user_id'] = 123;

// Append session ID to URLs
$url = 'http://example.com/page2.php?PHPSESSID=' . session_id();
echo '<a href="' . $url . '">Page 2</a>';