Dan Kanze
Dan Kanze

Reputation: 18595

IE8 only using first session cookie

Some background information about the problem:

My domain, is in this format: http://example.com/
Hosted On: Shared Hosting Server.
Protected Mode: Off.
Application suffers with: IE8.
Application doesn't suffer with: Chrome, or FireFox.

I log in to the application with the following:

function login(){
    session_regenerate_id();
    $_SESSION['thumbprint']=nonce(session_id().'thumbprint',86400);
}


function nonce($str,$expires){
    global $config;
    return sha1(date('Y-m-d H:i',ceil(time()/$expires)*$expires).$salt.$str);
}

After logging in, I log out with:

function logout(){
    session_unset();
    session_destroy();
    header("Location: http://example.com");
    die();
}

The Problem: If I log in, and log out, any other time I try to log in the session does not start. Why is this?

Upvotes: 0

Views: 618

Answers (1)

Dan Kanze
Dan Kanze

Reputation: 18595

I initially had:

session_regenerate_id();

But this will not work becuase according to PHP manual:

"session_regenerate_id() will replace the current session id with a new one, and keep the current session information."
http://php.net/manual/en/function.session-regenerate-id.php

And becuase IE8:

"uses the first session cookie set and not the last as in Firefox."
http://anvilstudios.co.za/blog/php/session-cookies-faulty-in-ie8/

To fix this problem all you need to do is set:

session_regenerate_id(true);

Which deletes old session id and forces IE8 to use the new one.

Upvotes: 1

Related Questions