Session variables not getting set but only in Internet Explorer and not on all machines

Posted by gaoshan88 on Stack Overflow See other posts from Stack Overflow or by gaoshan88
Published on 2010-05-18T23:20:52Z Indexed on 2010/05/18 23:40 UTC
Read the original article Hit count: 228

Filed under:
|
|

Logging into a site I'm working on functions as expected on my local machine but fails on the remote server but ONLY in Internet Explorer. The kicker is that it works in IE locally, just not on the remote machine.

What in the world could cause this? I have stepped through the code on the remote machine and can see the entered login values being checked in the database, they are found and then a login function is called. This sets two $_SESSION variables and redirects to the main admin page. However, in IE only (and not when run on local machine... this is key) the $_SESSION variables are not present by the time you get to the main admin page. var_dump($_SESSION) gives me what I expect on every browser when I am running this in my local environment and in every browser except IE 6, 7 and 8 when run on the remote server (where I get a null value as if nothing has been set for $_SESSION).

This really has me stumped so any advice is appreciated.

For an example... in IE, run locally, var_dump gives me:

array
'Username' => string 'theusername' length=11
'UserID'   => string 'somevalue' length=9

Run on the remote server (IE only... works fine in other browsers) var_dump gives me:

array(0){}

Code:

$User = GetUser($Username, $Password);
    if ($User->UserID <> "") { // this works so we call Login()...
        Login($User); // this also works and gives expected results. on to redirect...
        header("Location: index.php"); // a var_dump at index.php shows that there is no session data at all in IE, remotely.
    } else {
        header("Location: login.php");
    }


function Login($data) {
        $_SESSION['Username'] = $data->Username;
        $_SESSION['UserID'] = $data->UserID;
// a var dump here gives the expected data in every browser
    }

© Stack Overflow or respective owner

Related posts about php

Related posts about internet-explorer