0
votes

I've got a problem deleting cookies. It seems my logout routine which uses the unsetting cookie code here only removes cookies on the root path. When I try to check for cookies in php files lower down the directory structure (ajax calls to a directory with the scripts in) their still there. Is there any way to remove all cookies from all directory paths. When I set the cookies I use...

setcookie("MemberID",1234567890,time()+(365*86400),'/');

From my understanding putting the "/" at the end enables the cookies to be accessed throughout the entire directory structure (which is what I want), but I'd have though removing them (as per the link above) with the "/" on the end would do the same thing and globally remove them....

setcookie("MemberID", '', time()-1000, '/');

...but it doesn't seem to.

Hope that makes sense. Any help is greatly appreciated... I've spent hours trying to track down where random MemberID's are coming from when doing ajax operations!

Dan

1
It looks ok... You're correct about sending the root path which will enable the cookie for the entire site. I just tried your code locally and it worked brilliantly well here. - JimL
Ajax and caching can cause problems. Make sure it's not a cache issue. - CodeAngry

1 Answers

0
votes

The problem wasn't my code in the end. Was tracked down to something else. @JimL is correct.