Home > php教程 > php手册 > body text

IE、Firefox PHP设置cookie的区别

WBOY
Release: 2016-06-13 10:37:44
Original
849 people have browsed it

今天利用 Cookie 做网站的用户登录,经过调试,用
    setcookie("username", "username", time()+1000,"/php100/");
等储存用户的登录信息,然后利用
    setcookie("username", "", time()-3600);
做 退出,在IE下测试没有任何问题。既然做网站,就要兼容尽可能多的浏览器,呵呵。于是在 Firefox 中测试,登陆一切正常,当 推出时,遇到了麻烦。怎么也不会退出,用户总是在登录状态。于是查看了 IE、Firefox 中cookie记录的区别,经过测试,才恍然大悟。
原来如果没有指定 setcookie() 的第四个参数(合法路径参数),默认会把当前目录作为合法路径,而我测试的路径为:http://127.0.0.1/php/rss2fla/data/log.php ,所以导致登陆和退出时 所设置的 cookie 路径不同。
IE比Firefox要人性化,呵呵,当美指定路径时,会覆盖当前 IP 下的同名Cookie变量,而FireFox比较严格了,导致又重新建了个变量……
现在觉得垄断在某些方面也不是什么坏处,如果就 IE 一个浏览器,就不用这么麻烦了……哈哈……

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!