ie complicated subdomain cookie problem

2019-04-08 15:04发布

问题:

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.

回答1:

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.