对于域名投资者来说,当然是越短越好,然而对于IE来说,小于3位的域名就无法设置子域名COOKIE了。
最近就碰到这个BUG了,一直想不通IE为什么会出这种BUG,对于其他浏览器来说一点问题都没。
假设2台服务器如下:
127.0.0.1 www.6.cn
127.0.0.1 bbs.6.cn
在www.6.cn这台服务器上有个aa.php文件,源文件如下:
<?php setcookie("aa", "bb", time()+3600, "/", ".6.cn"); echo '<pre>'; print_r($_COOKIE); ?>
在bbs.6.cn这台服务器上有个bb.php文件,源文件如下:
<?php echo '<pre>'; print_r($_COOKIE); ?>
这2个程序的作用就是能使子域名共享COOKIE,结果却因为这个域名小于3位,瞎忙活了1天,如果域名换成3位或3位以上,就一点问题都没,比如把6.cn换成123.cn就很正常。
暂时还没有找到解决办法,先留个帖子,看看以后是否有时间解决。
参考资料:http://curl.haxx.se/rfc/cookie_spec.html
Only hosts within the specified domain can set a cookie for a domain and domains must have at least two (2) or three (3) periods in them to prevent domains of the form: “.com”, “.edu”, and “va.us”. Any domain that fails within one of the seven special top level domains listed below only require two periods. Any other domain requires at least three. The seven special top level domains are: “COM”, “EDU”, “NET”, “ORG”, “GOV”, “MIL”, and “INT”.

