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?

藏色散人
Release: 2023-03-03 10:10:02
Original
4618 people have browsed it

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,'/');
Copy after login

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!

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