Session Cookies - Bug in IE7

By nathan

Here is a problem I found recently, I had a website where the Session Cookies keep getting reset on every page load but it was happening just in IE7 not in Firefox, Safari, IE6 etc.

After a while I found the solution was that I had used an underscore character "_" in the domain (website) name e.g. my_website.localhost
This meant IE7 dropped the authentication cookie when there was an underscore in the domain name (possibly as it can not represent an underscore when it saves the referencing cookie session).

So I changed the domain name e.g. my-website.localhost and now the cookie sessions are fine in all browsers.

This is a weird problem but seems to be considered a general bug with IE7 and domain cookies. Hopefully IE8 will have a fix for this problem.

So for future reference don't use underscores in domain names, or be prepared to live without session cookies in IE7.