Jump to content
Sign in to follow this  
Richard_Grant

CookIes!

Recommended Posts

This is prob a stupid question.. but i've always wondered..

 

When deleting a cookie why do we use 

why do we use:

setcookie($name, '', time() - 3600, "/", "", 0);

 

when this works just fine:

setcookie($name, '', 0, "/", "", 0);

 

 

 

isn't the time() just a waste of space?

 

 

I ask this because everywhere i look i see:

setcookie($name, '', time() -3600 , "/", "", 0);

Share this post


Link to post
Share on other sites

Setting the expiration time to the past is a compatibility feature for Internet Explorer.

 

What people miss, however, is that PHP automatically sets the expiration time when you give it an empty value. So the time() stuff doesn't do anything and is arguably a waste of space.

Share this post


Link to post
Share on other sites

Setting the expiration time to the past is a compatibility feature for Internet Explorer.

 

What people miss, however, is that PHP automatically sets the expiration time when you give it an empty value. So the time() stuff doesn't do anything and is arguably a waste of space.

 

:) oh so i can just put ?

setcookie($name, '', NULL, "/", "", 0);

Without any compatibility issues?

Share this post


Link to post
Share on other sites

Yes. You can actually see it by inspecting the HTTP headers: The expires attribute is always “01-Jan-1970 00:00:01 GMT” (Unix time 1).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.