Home >Backend Development >PHP Problem >What should I do if php cannot obtain the cookie value?

What should I do if php cannot obtain the cookie value?

藏色散人
藏色散人Original
2020-07-25 10:20:524612browse

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.

What should I do if php cannot obtain the cookie value?

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!

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