SUMMARY: SESSIONS and COOKIES do not work in Internet Explorer when the subdomain name includes an underscore.
Another one of those weekends. Every now and then this happens. You wake up on a Saturday morning, the sun is shining (which is even more uncommon here in ireland than the issue in my story today) and you think “Today I’m not going to do anything. Just chill out for a change.” Then you check your email (mistake no. 1) to find a message from a website visitor telling me that there is something wrong with the translation of certain elements on my website. I’m still optimistic and convinced that this is probably a small thing and that I will only need a few minutes to fix this (mistake no.2).
A little bit of background information: On my website I link to preview websites so visitors can see what that particular website looks like and how it works. Because I work with multiple languages I use sessions to remember where a user is coming from to show certain elements in their language.
Now according to the email, this bit of translation was not correct – yet it worked perfectly fine for me. Digging a bit deeper I found that the author of this email was using Internet Explorer 8. I’m using Google Chrome and sporadically Mozilla FIrefox myself, but never Internet Explorer. Of course I know how horrible IE works with CSS, but I expected PHP to be working similar for all browsers (mistake no.3). For some reason the sessions just didn’t seem to stick in Internet Explorer 8 nor in version 7.
Then the research started. At times like these you wonder what people would have done without Google. I’ve searched for every set of keywords that slightly matched my problem, but nothing offered a solution. So at some point I decided to move away from sessions and start working with Cookies. A bit of a workaround but at this time I had been spending (read: loosing) so much time on Sessions that I wanted to try something else. But no joy: same issue still occurred only in Internet Explorer. To give you a bit of an idea, it was 7pm now, so the sun was long gone and there was no sign my nice chilled out Saturday anymore.
I kept on reading and trying out a million different things varying from year long expiration times (when the time on your server is off or your server is in a different timezone this becomes a serous problem in IE but the other major browsers only work with one time and don’t have this problem) to writing the sessions to a database. It just didn’t want to work.
And then… when I was reading the millionth blog post, way down in the comments, someone mentioned the use of underscores and that those could be problematic in Internet Explorer. Since I was using subdomains with names that included underscores (mistake no.4) it was worth testing this theory. As it turns out, Internet Explorer cannot cope with Sessions nor with Cookies for subdomains containing an underscore.
Seriously, Internet Explorer… I can understand why the EU is picking on Microsoft so much. Most internet users (I’m talking about laptop and desktop users now) are still running Windows and even though it now asks you which browser you want to use, Internet Explorer is the most well known and the one included in the package. But it is also the absolute worst of the worst. I would love to just ignore Internet Explorer browser issues but still about 1 in every 2 internet users is using it… we simply can’t. But if you are part of this group, if you are still using Internet Explorer, please realize that all the websites you see on the internet have required so much extra work to build, to function and to look as they do.
I will fix this problem on Monday, so luckily I still have my Sunday left. If only the weather was as good as yesterday…