php cookie 设置有关问题

WBOY
Release: 2016-06-13 11:48:44
Original
748 people have browsed it

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

<br />$nick=$_SESSION['user'];<br /><br />setcookie("user", $nick, time()+36000);<br />
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!