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
jaylin
Forum Commoner
Posts: 68 Joined: Fri Nov 18, 2005 4:44 am
Post
by jaylin » Wed Nov 30, 2005 3:15 am
now i store many values (like an array) in the cookie. although i use
Code: Select all
setcookie("mycookie","",time()-3600)
but, the values are still reamin. how can i clear them?
wh33t
Forum Newbie
Posts: 12 Joined: Wed Nov 30, 2005 2:09 am
Post
by wh33t » Wed Nov 30, 2005 3:27 am
You could clear them at the client level. Ie. Delete cookies from the Tools menu or whatever.
If you want to do it on the server level you could use unset() perhaps.
like
I think thats how unset works...
Check it out here
http://ca.php.net/manual/en/function.setcookie.php
jaylin
Forum Commoner
Posts: 68 Joined: Fri Nov 18, 2005 4:44 am
Post
by jaylin » Wed Nov 30, 2005 3:31 am
it doesn't work !!!
wh33t wrote: You could clear them at the client level. Ie. Delete cookies from the Tools menu or whatever.
If you want to do it on the server level you could use unset() perhaps.
like
I think thats how unset works...
Check it out here
http://ca.php.net/manual/en/function.setcookie.php
wh33t
Forum Newbie
Posts: 12 Joined: Wed Nov 30, 2005 2:09 am
Post
by wh33t » Wed Nov 30, 2005 3:32 am
Did you get an error message of some sort? Should probably post it if you did.
Also read up on that link I sent you. It will say how to delete and clear cookies.
Jenk
DevNet Master
Posts: 3587 Joined: Mon Sep 19, 2005 6:24 am
Location: London
Post
by Jenk » Wed Nov 30, 2005 5:26 am
The only way to delete a users cookie from the server is to force it to expire, like you have done.
Try including your domain and cookie path, like is found on the manual page for setcookie(), that should solve it I reckon.
AGISB
Forum Contributor
Posts: 422 Joined: Fri Jul 09, 2004 1:23 am
Post
by AGISB » Wed Nov 30, 2005 5:59 am
You can also set all values to ""
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Wed Nov 30, 2005 8:23 am
AGISB wrote: You can also set all values to ""
if you do that then a isset check will still return TRUE. you could set all the values to NULL but why not just delete the cookies by giving them a negative time (a time in the past) as he was originally doing.