I can't expire a cookie

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
User avatar
luna80
Forum Newbie
Posts: 5
Joined: Sun Sep 09, 2007 1:07 am

I can't expire a cookie

Post by luna80 »

Hi,
I have a problem with the setcookie function: I don't know why but the cookie doesn't expire.

I create the cookie with

Code: Select all

setcookie('cookie_name', $userid, time()+7776000);
and I try to expire it with

Code: Select all

setcookie('cookie_name', '', time()-7200);
but doesn't work.
If I check the expiration date of my cookie in the options of my browser and I see that the date is the same before and after calling setcookie with a past time...

Somebody can explain me why?

Thanks in advance
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Are these done in separate files?
User avatar
luna80
Forum Newbie
Posts: 5
Joined: Sun Sep 09, 2007 1:07 am

Post by luna80 »

feyd wrote:Are these done in separate files?
yes...the first is done in the login page and the second in the logout page.

do you know the problem?

thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Where (physically) is the login page relative to the logout page?
User avatar
luna80
Forum Newbie
Posts: 5
Joined: Sun Sep 09, 2007 1:07 am

Post by luna80 »

feyd wrote:Where (physically) is the login page relative to the logout page?
in the same place (same folder, if is that do you mean)
Post Reply