Weird cookie problem.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
oscardog
Forum Contributor
Posts: 245
Joined: Thu Oct 23, 2008 4:43 pm

Weird cookie problem.

Post by oscardog »

So on a page(/dir/dir1/) I set a cookie, right after setting the cookie I echo the value out to test if it worked. It outputs the value.

I then try to use an isset() on another page (/dir/) and it returns the cookie as empty. I go into the privacy tab in firefox to view the cookies and it has my cookies stored there with the value I set.

So why when I try to use the cookie does it not work?

Edit: Well that was quick. Apparently if you set the cookie in /foo/bar/ you can only access it from /foo/bar/ and 'above'. So if you try to access it in /foo/ it wont work. Fixed by setting the option "path" parameter.
Post Reply