Cookies...again...

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
dwfait
Forum Contributor
Posts: 113
Joined: Sun Aug 01, 2004 10:36 pm

Cookies...again...

Post by dwfait »

Hi. My expire code doesnt seem to be working on my cookies. Here is the code:

Code: Select all

setcookie ("username", $ssppluser,time()-43200);

//code to set the cookie:

setcookie ("username", $ssppluser,time()+43200);
So, im looking for another way. How would you delete the cookie entirely?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$ssppluser has to be non-empty (to be set).. also, make sure the path and domain are readable where you are wanting it to be read..
dwfait
Forum Contributor
Posts: 113
Joined: Sun Aug 01, 2004 10:36 pm

Post by dwfait »

The cookie is created okay, and my script reads the variable i set in there ok, it just wont..not work.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you mean deleting the cookie? the value should be an empty string..
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

feyd is saying to do this

=]

setcookie ("username", "" ,time()-43200);
dwfait
Forum Contributor
Posts: 113
Joined: Sun Aug 01, 2004 10:36 pm

Post by dwfait »

Thanks a lot guys.
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Setting the cookie to null is a great logout procedure! Just thought I should say :D
dwfait
Forum Contributor
Posts: 113
Joined: Sun Aug 01, 2004 10:36 pm

Post by dwfait »

lol. What do you suggest then?
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

dwfait, that is the only way to expire cookies on the go.

Unless you set it for an hour, and a hour passes, the code I gave is the only way

If u read what joe said, he said it is a good logout way, which pretty much is the only logout way with cookies


thought I should say that :roll:
dwfait
Forum Contributor
Posts: 113
Joined: Sun Aug 01, 2004 10:36 pm

Post by dwfait »

thought he was being sarcastic :? lol
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

lol, no I was not being sarcastic.
Post Reply