Home  >  Article  >  Backend Development  >  What should I do if I can't get the php cookie?

What should I do if I can't get the php cookie?

hzc
hzcOriginal
2020-06-23 11:46:002250browse

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!

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