Sunday, February 14, 2010

PHP Session Variable Value Lost Internet Explorer




PHPImage via Wikipedia
Recently i met a condition in PHP where session variable value is lost, since the variable is used for storing login session id so user must login again if that value is lost, this issue only happen with Internet Explorer not with other browser.



After googling and reading many articles there are lots of similar condition occur with different cause such as redirecting with header assign, P3P issue, using Frameset and so on...but my condition is different. I never suspect that using blank image source at img tag will cause this. So i thought it probably useful sharing this info for others. I try to confirm this issue by reading http://php.net/manual/en/ref.session.php and there is one user with exact problem like me.
<img src=""></img>
This snippet will cause Internet Explorer erasing Session variable value when user move to other menu, so to solve this is really simple just put initialization source value for the tag, in my case img tag will load dynamic png image generated from other page.
<img src="otherpage.php"></img>
Thats it...its harder finding the problem then to solve it....

Regards,
REV
Reblog this post [with Zemanta]

1 comments:

Anonymous said...

Just want to say thanks. I had something like that going on and your post gave me some direction (I found it on some other web site too, but yours was the first I found). At the end, it was in some of my javascript, I was removing the source of an image, giving it a new one about 10 lines after and was making the session to drop... but only in IE.. so instead of leaving the source empty, I put the source of a blank image until I change it back 10 lines later.

Thanks again.