Home > Article > Backend Development > What should I do if I can’t get the php cookie?
#php What should I do if I can’t get the cookie?
The default path of setcookie() is in the current directory. If other directories want to access this cookie, it will not be accessible.
If this parameter is set to '/', the cookie will be Valid in the entire domain
If set to '/foo/', the cookie will only be valid in the /foo/ directory and its subdirectories under the domain
For example, /foo/bar/. The default value is the current directory where the cookie is set.
只需要更改路径就可以了 setcookie("viewlist",1,time()+3600*24*365,'/');
Recommended tutorial: "php tutorial"
The above is the detailed content of What should I do if I can’t get the php cookie?. For more information, please follow other related articles on the PHP Chinese website!