php cookie 设置问题

WBOY
Release: 2016-06-23 14:02:05
Original
767 people have browsed it

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

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


在另一个页面 echo $_COOKIE["user"]; 输出是空,但是$nick是有值的,求解这是为什么。


回复讨论(解决方案)

是不是浏览器禁用了cookie

cookie 是有作用路径的
默认是当前目录,即两个页面的路径相同

setcookie("user", $nick, time()+36000,"/");

Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template