why does my php session information behave differently on a different server
<p>I'm writing a simple web site php/jquery/mysql etc. Currently I've a pretty simple login system where once the user logs in a session variable is set that is referenced to confirm if they're still logged in on other pages. Code is:</p>

<pre><code>$_SESSION['logged_in'] = TRUE;
$_SESSION['member_id'] = $member_id_for_session;
$_SESSION['handle'] = $user_handle;
</code></pre>

<p>I have a variety of functions in util files that make use of this such as:</p>

<pre><code>function echoUserHandle() {
    if (isset($_SESSION['handle'])) {
        echo "Welcome " . $_SESSION['handle'];
    } else {
        echo "You are not logged in";
    }
}
</code></pre>

<p>and</p>

<pre><code>function checkLoggedIn() {

if (isset($_SESSION['logged_in'])) {
    return TRUE;
} else {
    return FALSE;
}
}
</code></pre>

<p>this works fine on my MAMP server on my mac using chrome however when I push it out to my remote server I get inconsistent views of the data even on the same browser I use to dev on. I see this only by the fact that some pages show the status "You are not logged in" whilst some display the correct user id.</p>

<p>Also once a user is logged out the session is destroyed fully using:</p>

<pre><code>        unset($_SESSION['logged_in']);
        unset($_SESSION['member_id']);
        unset($_SESSION['handle']);
        $_SESSION = array();

        if (ini_get("session.use_cookies")) {
            error_log("unsetting cookie:" . session_name(), 0);
            $params = session_get_cookie_params();
            error_log("cookie params:" . $params, 0);
            setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]);
        }

        session_destroy();
</code></pre>

<p>this might be overkill but, when I log back in as a different user on some pages it still displays the previous logged in user. This suggests something wrong with the session doesn't it?</p>

<p>Can anyone suggest an approach to debug this, I've done a lot of dev in other fields but php is still new to me.</p>

<p>Many thanks</p>
