Home  >  Article  >  Backend Development  >  php cookie 设置有关问题

php cookie 设置有关问题

WBOY
WBOYOriginal
2016-06-13 11:48:44718browse

php cookie 设置问题
以下这段代码,获取cook的值是空的

<br />$nick=$_SESSION['user'];<br /><br />setcookie("user", $nick, time()+36000);<br />


在另一个页面 echo $_COOKIE["user"]; 输出是空,但是$nick是有值的,求解这是为什么。
------解决方案--------------------
是不是浏览器禁用了cookie
------解决方案--------------------
cookie 是有作用路径的
默认是当前目录,即两个页面的路径相同
------解决方案--------------------
setcookie("user", $nick, time()+36000,"/");

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