Page 1 of 1

Session Values Not Retained in IE

Posted: Mon May 14, 2007 9:45 am
by N1gel
Hi

i've just started to get this weird error with sessions in internet explorer. Some aren't being retained. I've tried to break it down to its simplist.

At the end off my log in page i printo out these session values

Code: Select all

echo "User : ".$_SESSION["username"]."<br>";
echo "Level : ".$_SESSION["userlevel"]."<br>";
and they print out fine like so

User : admin
Level : 0

however at the beginning off the next page i use the code

Code: Select all

session_start();

echo "User : ".$_SESSION["username"]."<br>";
echo "Level : ".$_SESSION["userlevel"]."<br>";
and i get the print out

User1 :
Level1 :

the strangest thing is if i set a new session value at the bottom of my login page like

Code: Select all

echo "User : ".$_SESSION["username"]."<br>";
echo "Level : ".$_SESSION["userlevel"]."<br>";
$_SESSION["test"] = "test";
only that will be displayed on the next page using this code

Code: Select all

echo "User : ".$_SESSION["username"]."<br>";
echo "Level : ".$_SESSION["userlevel"]."<br>";
echo "Test : ".$_SESSION["test"]."<br>";
User :
Level :
Test : test


And to make things worse it only happens in IE 6 and IE 7 it works fine in Firefox and i also in ZZEE Script GUI which i use on my machine for testing.

i also have other websites on the same server running with sessions working fine in IE it strange this just started happening on this page.

If anyone knows a reason why IE might do this i would be greatful to hear any input.

Note
I have made sure there are no illegal characters in the url as i here this can stop session working in IE


Thanks to anyone who might be able to help

Nigel :D

Posted: Mon May 14, 2007 12:05 pm
by RobertGonzalez
Have a look at your cookies to see if they are setting properly. There may be a problem with that. Also, see if you can keep track of your IP address as you turn the pages to see if the IP address is changing (not that this would be an enormous issue, but humor us). Also, look into var_dump() of the $_SESSION array from page to page, as well as session_id().

Posted: Tue May 15, 2007 5:31 am
by N1gel
Thanks for the response.

Although i decided to just start commenting sections off my code out until i could narrow down the problem, and for some strange reason i narrowed it down to these two lines in my menu code.

echo "<a>&nbsp;";
echo "<img src='' alt='' title='' width=0 height=0 border=0/></a>";

It was a really cheap fix to try and make a blank span behave the same as my menu buttons so they all aligned corretly. i have now fixed that properley with css.

But i have no idea why those lines would make IE throw a wobbler with my php session values.

weirdest and most annoying error ever, several frustrating days for that what a joke

thanks again