What is the issue with PHP sessions in Firefox when multiple users log in on different tabs or windows?

When multiple users log in on different tabs or windows in Firefox, the PHP session cookie is shared across all tabs/windows. This causes conflicts with session data and can lead to users unintentionally accessing each other's accounts. To solve this issue, you can append the session ID to the URL for each page request.

<?php
session_start();

if (!isset($_SESSION['username'])) {
    $_SESSION['username'] = 'example_user';
}

$session_id = session_id();
$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]?PHPSESSID=$session_id";

header("Location: $url");
exit;
?>