前两天,在测试服务器上通过配置host来测试系统,发现在IE下面cookie的读写存在问题,一开始以为是代码和框架的问题,于是写了一个最简单的PHP页面来读写,发现依然不行。通过fiddler抓包软件发现cookie确实有正常的传输,说明网络是OK的。后来怀疑是php配置的问题,于是将PHP语言转换为JS来读写COOKIE,发现依然不行。后来无意中一个测试的同事通过域名直接访问,在IE下的cookie读写正常,于是怀疑是域名中有特殊的字符因为了IE对cookie解析的异常。经过排查,发现域名中带有“_”的域名都会引起IE cookie异常。将_去掉,一切正常。最后通过查找资料发现如下的信息:
According to RFC1035 (Domain names - implementation and specification):
[domain names] must start with a letter, end with a letter or digit, and have as interior characters only letters, digits, and hyphen.
Turns out some of the domains had an underscore ( "_" ) in them: some_domain.example.com. Although this is a violation of the RFC, all other browsers work normally.
MSIE 7, on a domain with an underscore, silently drops all cookies for that host and refuses to accept new ones.
The 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).
根据RFC1035规则,域名的实现和规范必须以字母开头,以字母或者数字结束,其他的部分必须数字,字母或者连字符-。
同时提到msie7,域名中包括_,将会丢弃掉所有的cookie并拒绝接受新的。
域名引起的IE cookie不能使用的问题,布布扣,bubuko.com
原文:http://skindx.blog.51cto.com/2855260/1439840