Cookies not being deleted

Thread Solved

Join Date: Sep 2008
Posts: 46
Reputation: Zurompeta is an unknown quantity at this point 
Solved Threads: 0
Zurompeta Zurompeta is offline Offline
Light Poster

Cookies not being deleted

 
0
  #1
Sep 19th, 2008
Hi everyone,

Got a pesky little issue here with cookies. I have searched numerous forums and numerous posts of how to delete a cookie. So, I am much aware of this doing the trick:

  1. setcookie('cookie_name');

Basically where not assigning any value to a cookie will delete it. (This is just to save some time )

Anyways, I wish this was the case, but it's not working. I got it to work on a different portion of my application. However I had to come at it a different angle.

Basically, the way I wanted it to be was a user clicks the "logout" button and the cookies would be deleted and after being deleted, the user would be re-directed to the login page. But, instead I had to make a "logout.php" where the user is directed to this page, the delete cookie works fine, THEN gets directed to the login page.

I would use this technique for my current task in my application, but this would greatly complicate things.

Thanks in advance for any help.
Last edited by Zurompeta; Sep 19th, 2008 at 6:49 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 234
Reputation: PoA is an unknown quantity at this point 
Solved Threads: 8
PoA PoA is offline Offline
Posting Whiz in Training

Re: Cookies not being deleted

 
0
  #2
Sep 20th, 2008
  1. setcookie('cookie_name', time() - 42000);
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 2
Reputation: iPHP is an unknown quantity at this point 
Solved Threads: 1
iPHP iPHP is offline Offline
Newbie Poster

Re: Cookies not being deleted

 
0
  #3
Sep 20th, 2008
actualy its

  1. setcookie('cookie_name', null, time() - 3600);
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 46
Reputation: Zurompeta is an unknown quantity at this point 
Solved Threads: 0
Zurompeta Zurompeta is offline Offline
Light Poster

Re: Cookies not being deleted

 
0
  #4
Sep 21st, 2008
Originally Posted by iPHP View Post
actualy its

  1. setcookie('cookie_name', null, time() - 3600);
*sigh*


See, I know this line of code should be working but it's just not, this is so frustrating. Does this line of code only work in IE or something?
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 525
Reputation: Will Gresham is on a distinguished road 
Solved Threads: 86
Sponsor
Will Gresham's Avatar
Will Gresham Will Gresham is offline Offline
Posting Pro

Re: Cookies not being deleted

 
0
  #5
Sep 21st, 2008
Do you have a re-direct on the logout.php script? If you do comment this out and run the code to see if the cookies are being deleted at all, its possible depending on how your script works that it is re-creating the cookies when the user is re-directed.

The code is not browser defendant since PHP is a server side language not client side.

Personally I use the following code to delete cookies, but it does exactly the same as the previous examples:
  1. $past = time() - 3600;
  2. setcookie('cookie_name', null, $past);
Last edited by Will Gresham; Sep 21st, 2008 at 6:18 pm.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 2
Reputation: iPHP is an unknown quantity at this point 
Solved Threads: 1
iPHP iPHP is offline Offline
Newbie Poster

Re: Cookies not being deleted

 
0
  #6
Sep 21st, 2008
try installing Firebug in Firefox and watch the console to see if the cookie is deleted or not
and after that is it recreated or not

Useful Plugins :
- Firebug
- Firecookie
- Web Developer
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 46
Reputation: Zurompeta is an unknown quantity at this point 
Solved Threads: 0
Zurompeta Zurompeta is offline Offline
Light Poster

Re: Cookies not being deleted

 
0
  #7
Sep 22nd, 2008
I'd like to thank those who took the time to share their knowledge/input. Oddly enough it just decided to work, I might have done something I'm not sure about that fixed it, but all is good now (yay for programming lol).

Also, I love Firebug iPHP, so no worries there
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 3
Reputation: PixelCoder is an unknown quantity at this point 
Solved Threads: 0
PixelCoder PixelCoder is offline Offline
Newbie Poster

Re: Cookies not being deleted

 
0
  #8
Jan 17th, 2009
Hello,

I realise this has now been resolved.. but is it possible that the problem was something to do with the path of your cookies?

For example: Your login page was creating a cookie and directing the user to the members page within a subdirectory, then the logout page was trying to delete a cookie which existed in the subdirectory instead of the root where it was created?

Pixel =)
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum


Views: 1129 | Replies: 7
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC