PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
InternetX
Forum Newbie
Posts: 22 Joined: Tue Jan 21, 2003 1:57 pm
Location: Germany
Contact:
Post
by InternetX » Sun Feb 16, 2003 9:35 pm
How can I delete a cookie that I set before with setcookie(...)?
A new cookie with the same name doesn't kill the old cookie
Can anyone help me?
Sorry 4 my english... I'm 14 and from Germany...
phice
Moderator
Posts: 1416 Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:
Post
by phice » Sun Feb 16, 2003 11:20 pm
Simply set the cookie's value to nothing.
bionicdonkey
Forum Contributor
Posts: 132 Joined: Fri Jan 31, 2003 2:28 am
Location: Sydney, Australia
Contact:
Post
by bionicdonkey » Mon Feb 17, 2003 2:35 am
set the cookie again but change the time to a negative value so it expires
e.g.
setcookie ("TestCookie", $value,time()+3600); /* expire in 1 hour */
setcookie ("TestCookie", $value,time()-3600); /* expired 1 hour ago*/
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Mon Feb 17, 2003 3:02 am
setcookie() :
When deleting a cookie you should assure that the expiration date is in the past, to trigger the removal mechanism in your browser.
Don't forget that you need to refresh the page before you can test for the existance or lack of the cookie.
Mac
InternetX
Forum Newbie
Posts: 22 Joined: Tue Jan 21, 2003 1:57 pm
Location: Germany
Contact:
Post
by InternetX » Mon Feb 17, 2003 6:29 am
I already have test this...
But my cookie will not be deleted
I will test it again... thanks for help