IE下COOKIE失效的一种特殊情况

setcookie ("name", "value", 0, "/", ".example.com");

使用以上代码设置cookie后,在非IE(chrome、firefox等)下访问 test_1.example.com 均可正常获取;使用IE访问则获取不到该cookie。

访问 test.example.com 任何浏览器均可正常获取。


本来以为是setcookie参数问题,后来以为是两套代码不同问题,发现都不是。

最后发现是域名问题:域名中不能含有“_”(下划线)。。。

------------------------------我是分割线-------------------------------

RFC 952 有明文规定
 
 A "name" (Net, Host, Gateway, or Domain name) is a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-), and period (.) . Note that periods are only allowed when they serve to delimit components of "domain style names". (See RFC-921, "Domain Name System Implementation Schedule", for background). No blank or space characters are permitted as part of a name. No distinction is made between upper and lower case. The first character must be an alpha character. The last character must not be a minus sign or period. A host which serves as a GATEWAY should have "-GATEWAY" or "-GW" as part of its name. Hosts which do not serve as Internet gateways should not use "-GATEWAY" and "-GW" as part of their names. A host which is a TAC should have "-TAC" as the last part of its host name, if it is a DoD host. Single character names or nicknames are not allowed.


虽然很多网站,甚至是某些知名网站的一些二级域名仍有采用这种不规范命名,但大家在平时使用中还是最好应尽量避免使用带有下划线的域名。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值