Home >Backend Development >PHP Problem >What should I do if php cannot obtain the cookie value?
php cannot obtain the cookie value because the access path is set incorrectly. The solution is to change the path to "setcookie("viewlist",1,time() 3600*24*365,'/') ;" That's it.
Recommended: "PHP Tutorial"
php cannot get cookie value
The default path of setcookie() is the current directory. If other directories want to access this cookie, they will not be able to access it. If this parameter is set to '/', the cookie will be valid in the entire domain. If it is set to '/' foo/', the cookie is only valid in the /foo/ directory and its subdirectories under domain, such as /foo/bar/. The default value is the current directory where the cookie is set.
Just need to change the path
setcookie("viewlist",1,time()+3600*24*365,'/');
The above is the detailed content of What should I do if php cannot obtain the cookie value?. For more information, please follow other related articles on the PHP Chinese website!