DELETE COOKIE!!! You hear me?!!!!

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

Post Reply
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

DELETE COOKIE!!! You hear me?!!!!

Post by Steveo31 »

Oh man, this is really irkin me the wrong way.

No matter how many combos of setcookie, I can't get one to delete.

Code: Select all

setcookie("log", $cookies['username']."-".$cookies['email'], time()+2278326, '/'); //+ about 1 month
And to, what I thought was deletion...

Code: Select all

setcookie('log', FALSE, time(), '/');
But noooooooooooo, that's too easy.

Still there. Argh!! :evil:
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

You use setcookie() to set a cookie with the same name as the one you want to delete, but set the expire time to (time() - 2278326).
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

the answer was already given: make sure the expiration date of the cookie is in the past..

instead doing calculations yourself:
[php_man]strtotime[/php_man]

fe:

Code: Select all

strtotime("now +2 months")
will give you a date 2 months from now...
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

Knew it was simple. Thanks guys.

And yea, Tim, I did that elsewhere, but my hand had a spasm on the keypad for this one, heheh ;)
Post Reply