« Speed Up Visual Studio 2005
» Beer Brewing Bender


PHP, Cookies, and Internet Explorer 6

Adam Kinder | 12.06.07 | PHP, Programming
php-cookies-and-internet-explorer-6

Nothing is more hair-pulling than working IE6 and creating workarounds. Every E29 product has a session workaround specifically for IE6 that I thought was unsolvable, until now.

If you’re having trouble with IE6 accepting login cookies, or any cookies, using PHP, you definitely want to read on for the off the wall answer to your problem.

With the Great Daylight Savings Change of 2007, I had the wonderful experience of having applications and servers go down because of timezone issues. Oracle DB 10.2g was especially prone to this issue, and it caused a huge problem with data consistency until I devised a solution. ( Which was at the time, tell the server it was in Hawaii ).

After that mess, I started working more with timestamps and accuracy as per GMT + DST, server times versus local times in regards to timeouts, and so on. One bug that has plagued me for years is the IE6 cookie login issue.

To summarize, a client machine with Firefox and IE7 will be able to login and accept cookies from a site, but IE6 won’t. I had tried everything, including URL session ids, adding a P3P policy to the website headers, everything.

What I didn’t try, and was very noobish of me, was to calculate the expiration times of the cookie sessions in relation to the browser. What I found was pure hilarity, and caused me to want to sue Microsoft for lost productivity.

In short, and well documented on the intarwebs, is that IE6 follows the RFC for cookie expirations, and doesn’t convert them into UTC time. Instead they use the machine time against the local time, meaning timezone differences completely blow your cookies up.

IE7 thankfully corrects this, and Firefox never had the problem.

In my case, I was mostly being bitten by not correctly handling timezone differences and DST. But, in a few cases, just like the link above, the server time turned out to be wildly off and was causing IE6 to expire any cookies immediately.

The fix documented above for a timezone issue is to sync your server with NTP using the following commands:
$ ntpupdate pool.ntp.org
$ tzselect

This will sync up your server, and then allow you to set up the correct timezone.

I hope this post helps any other PHPer, or any coder, if they are having the same issues.

6 Comments

:

:


« Speed Up Visual Studio 2005
» Beer Brewing Bender