Home >Backend Development >PHP Tutorial >网站根目录下的程序获取不了子目录生成的cookies?

网站根目录下的程序获取不了子目录生成的cookies?

WBOY
WBOYOriginal
2016-06-23 13:44:13916browse

RT,网站根目录下的程序获取不了子目录生成的cookie,子目录可以正常获取,cookie的作用域不是整站的吗  


回复讨论(解决方案)

echo $_COOKIE['xx']  没有任何输出...子目录下正常输出

在默认的情况下,cookie 的路径是当前路径,即:子目录中生成的 cookie 变量只能在子目录中访问
如果你需要在全站都能访问到,需要给 setcookie 函数的第 4 个参数赋值 /

Statement:
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