almightyegg Posted July 31, 2007 Share Posted July 31, 2007 My logout page desn't actually log you out, infact it does nothing.... I tried deleting cookies like this but to no avail... setcookie(email, $email, time() - 3600*24); setcookie(password, $password, time() - 3600*24); How do I do it? Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/ Share on other sites More sharing options...
realjumper Posted July 31, 2007 Share Posted July 31, 2007 setcookie("email", "", time() - 3600); setcookie("password", "", time() - 3600); Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312250 Share on other sites More sharing options...
almightyegg Posted July 31, 2007 Author Share Posted July 31, 2007 Nope, still doesn't log out :-/ Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312251 Share on other sites More sharing options...
realjumper Posted July 31, 2007 Share Posted July 31, 2007 Hmmm...that works for me. Can you look at your cookies? I just used this exact code and watched my cookie vanish on logout Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312255 Share on other sites More sharing options...
almightyegg Posted July 31, 2007 Author Share Posted July 31, 2007 My cookies were made to last 3600*24 , do I have to delete them with the same time? Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312263 Share on other sites More sharing options...
almightyegg Posted July 31, 2007 Author Share Posted July 31, 2007 echoed out the cookies after I had placed the code to delete them and they are there still... Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312267 Share on other sites More sharing options...
realjumper Posted July 31, 2007 Share Posted July 31, 2007 My cookies were made to last 3600*24 , do I have to delete them with the same time? No, if you are logging out then you want to destroy the cookie. To destroy the cookie you need to set it's time the past and also give it an empty value. setcookie ("my_cookie", "Logged_in", time()+3600); //the cooikie 'my_cookie' will last for 3600 seconds, or one hour from the current time. and setcookie ("cookie", "", time()-3600); //will delete the cookie Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312277 Share on other sites More sharing options...
almightyegg Posted July 31, 2007 Author Share Posted July 31, 2007 this is my code <? setcookie("email", "", time() - 3600); setcookie("password", "", time() - 3600); $email = $_COOKIE['email']; $password = $_COOKIE['password']; ?> <html> <title>Logout</title><link rel="stylesheet" href="default.css"> <body bgcolor="black"> Thanks for playing. Please come back soon. <? echo "$email, $password"; ?> </body> </html> I can't spot any reasons why it's not deleting Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312279 Share on other sites More sharing options...
realjumper Posted July 31, 2007 Share Posted July 31, 2007 Okay...I just ran this quick test.... setcookie("email", "yipee", time()+3600); The above set a cookie called 'email' with the value of 'yipee'. setcookie("email", "", time()-3600); The above immediately deleted the cookie. Try it :-) Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312317 Share on other sites More sharing options...
almightyegg Posted July 31, 2007 Author Share Posted July 31, 2007 Now I'm really confused! I tried it, making it called yippie, destroyed it, echoed it and it echoed my email address that I logged in with..... wth? Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312328 Share on other sites More sharing options...
realjumper Posted July 31, 2007 Share Posted July 31, 2007 Now I'm really confused! I tried it, making it called yippie, destroyed it, echoed it and it echoed my email address that I logged in with..... wth? But the name of the cookie is 'email'.....it's value is 'yipee'. If you echo 'email' you should get 'yipee' returned..... setcookie("email", "yipee", time()+3600); echo $_COOKIE["email"]; // returns 'yipee' Delete all your browsers cookies so we can start fresh. Create the cookie named 'email' and give it a value of 'yipee'. Echo out the cookie and you should get 'yipee' on the page. Next, delete the cookie and echo it out and you should get nothing... setcookie("email", "", time()-3600); echo $_COOKIE["email"]; // returns nothing at all Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312335 Share on other sites More sharing options...
almightyegg Posted July 31, 2007 Author Share Posted July 31, 2007 It worked...then why won't it with the other values#?? Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312342 Share on other sites More sharing options...
realjumper Posted July 31, 2007 Share Posted July 31, 2007 It should work with any value....that's the syntax that I use for many different cookies and they all work just fine Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312351 Share on other sites More sharing options...
almightyegg Posted July 31, 2007 Author Share Posted July 31, 2007 <? setcookie("email", "", time() - 3600); setcookie("password", "", time() - 3600); ?> <html> <title>Logout</title><link rel="stylesheet" href="default.css"> <body bgcolor="black"> Thanks for playing. Please come back soon. <? $email = $_COOKIE['email']; $password = $_COOKIE['password']; echo "$email, $password"; ?> </body> </html> That's what I have put yet still it echoes it all out still.... Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312353 Share on other sites More sharing options...
realjumper Posted July 31, 2007 Share Posted July 31, 2007 Okay...after you have run the code and it still echo's out the email and password values....just hit the Refresh button and I betcha you'll get 'Thanks for playing. Please come back soon. ,' echoed out. Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312365 Share on other sites More sharing options...
almightyegg Posted July 31, 2007 Author Share Posted July 31, 2007 I refreshed about 20 times to make sure, still all there Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312371 Share on other sites More sharing options...
realjumper Posted July 31, 2007 Share Posted July 31, 2007 Hmmmm....when I run your exact code I watch the cookie vanish. But, as you say, the value still appears when I echo it out....BUT...when I refresh then the echoed valuesa aren't there anymore....because the cooi isn't there either!! What about this.... 1. Delete your cookies and redirect <?php setcookie("email", "", time() - 3600); setcookie("password", "", time() - 3600); Header("Location: test.php"); ?> 2. On test.php, echo the value of the cookies <html> <title>Logout</title><link rel="stylesheet" href="default.css"> <body bgcolor="black"> Thanks for playing. Please come back soon. <?php $email = $_COOKIE['email']; $password = $_COOKIE['password']; echo "$email, $password"; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312379 Share on other sites More sharing options...
almightyegg Posted July 31, 2007 Author Share Posted July 31, 2007 can sill view them Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312382 Share on other sites More sharing options...
realjumper Posted July 31, 2007 Share Posted July 31, 2007 Well.... there is something wierd going on because it works for me in Opera, MSIE, Firefox, Safari on a Windoze box and on MAC Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312388 Share on other sites More sharing options...
almightyegg Posted July 31, 2007 Author Share Posted July 31, 2007 I thought there was, plus I'm sure it used to work *shrugs* I'll google cookie detroyiong to see if thereare any alternatives. Thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312393 Share on other sites More sharing options...
realjumper Posted July 31, 2007 Share Posted July 31, 2007 Have a look at this http://www.spoono.com/php/tutorials/tutorial.php?url=cookies Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312394 Share on other sites More sharing options...
almightyegg Posted August 1, 2007 Author Share Posted August 1, 2007 here something seriously wrong here.....that didn't work either Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312397 Share on other sites More sharing options...
realjumper Posted August 1, 2007 Share Posted August 1, 2007 Can you try another browser? Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312399 Share on other sites More sharing options...
almightyegg Posted August 1, 2007 Author Share Posted August 1, 2007 I don'thave another.... :-/ this is IE7 Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312402 Share on other sites More sharing options...
realjumper Posted August 1, 2007 Share Posted August 1, 2007 Download one!!! ;-) Quote Link to comment https://forums.phpfreaks.com/topic/62741-solved-problems-deleting-my-cookies/#findComment-312404 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.