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

php cookie 设置问题

WBOY
WBOYOriginal
2016-06-23 14:02:05671browse

以下这段代码,获取cook的值是空的

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


在另一个页面 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