ohdang888 Posted April 22, 2009 Share Posted April 22, 2009 this is sorta confusing to say, but i gotta try. I have a "brain.php" located in the "folder" include from the root directory. Every file on my server includes this file, and it sets COOKIES of hashed keys to recongize and automatically log in users. When i go to logout.php, located in the root directory, it destorys the cookies. Now they must log in again to be recongized as a logged in user. When i go to logout.php, it successfully destorys my session and cookies, and redirects me to index.php of the root directory. Any file in the root directory says i'm logged out. That's good, that's what i want. BUT, when i go to another directory, like "/testing" or "/beta", which includes the same brain.php file, all files in other directories automatically log me in....in other words, this is my question: It seems as though the cookies of the root directory are just being deleted, even though i am setting the same cookie anywhere. Are cookie's url sensitive? How would i destory all cookies for the entire domain? this is my cookie destorying code: $_SESSION = array(); setcookie("key1", NULL,time() + 1); setcookie("key2", NULL,time() + 1); Link to comment https://forums.phpfreaks.com/topic/155136-solved-problems-with-cookies/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 22, 2009 Share Posted April 22, 2009 The 4th setcookie() parameter is the path. Without it, each setcookie() in a different path is setting a different cookie. To log someone out, you should only depend on a value stored on your server to tell you what the actual in/out status is. The cookie should only identify who they are. Doing this also saves you the trouble of needing to delete the cookie. Link to comment https://forums.phpfreaks.com/topic/155136-solved-problems-with-cookies/#findComment-816096 Share on other sites More sharing options...
ohdang888 Posted April 22, 2009 Author Share Posted April 22, 2009 yes that solves it! thanks! Link to comment https://forums.phpfreaks.com/topic/155136-solved-problems-with-cookies/#findComment-816403 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.