ie complicated subdomain cookie problem

Tag: internet-explorer , cookies , header Author: mkmkmkmk2009 Date: 2009-12-06

all my cookies work great on subdomain, but if subdomain has "_" in it, then cookie dont get read at all and dont get right at all eaither. following are my tested result, which will self explain

justlife.demo.com        *** works fine ***
just-life.demo.com       *** works fine ***
just-.demo.com           *** works fine ***

just_.demo.com           *** DONT works fine ***
just_life.demo.com       *** DONT works fine ***

domain that dont work, the cookies for them shows completely emtpy and you cant write or read from that sub-domains..

this problem is only in IE.

firefox and chrome works fine, they dont have this error.

any solutions? these subdomains are usernames.

Best Answer

IE has problems with underscores in sub domain namens. See the question here.

From there:

MSIE 7, on a domain with an underscore, silently drops all cookies for that host and refuses to accept new ones.

only solution is to use RFC-compliant domains (I've replaced all the "_"s with "-"s and set up a RewriteRule so that traffic is redirected to the compliant domains).

I'm afraid you are going to have to drop the underscore domains, or work around your cookie problem.

comments:

thank you... do you know how can i find sub-domain in url and re-write the rule, its best if i get subdomians and put that in end or url with &username=subdomain.. can you help me on this.
That's possible to do. Open a new question and add mod_rewrite as a tag, somebody will be able to help along.