Cookies not working on different pages

Which directory are you in when the cookie gets set?

From the PHP manual on setcookie(), emphasis mine:

Path

The path on the server in which the cookie will be available on. If set to “https://stackoverflow.com/”, the cookie will be available within the entire domain . If set to ‘/foo/’, the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain . The default value is the current directory that the cookie is being set in.

Leave a Comment