...

View Full Version : Dissappearing Cookie



Candrias77
05-20-2004, 10:37 PM
Hi there, I am having trouble accessing a cookie on different pages of my site. I have print_r($_COOKIE); at the top of two different pages, one returns the cookie contents, the other returns Array ( ).

I set the cookie is set at:
http://www.domain.com/login/index.php and print_r($_COOKIE); returns the cookie value once the user is logged in and the cookie is set.

On the page:
http://www.domain.com/activities/activity1.php the print_r($_COOKIE); request returns an empty array: Array ( ).

Note, I can surf the site and then go back to http://www.domain.com/login/ and it will still show the cookie contents, it only seems to "disappear" when I am on certain pages.

Are there any obvious causes for this?

Thanks

Candrias77
05-20-2004, 11:35 PM
Quite simple in end.

The problem was that the cookie was registered from a sub-directory on the site but I had left the directory attribute of setcookie() as empty, there for it was only available to files within that directory (and it's sub-directories).

Correct code was to set the cookie with: setcookie('cookiename', $login_value, 0, '/');



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum