Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cookie 1

Status
Not open for further replies.

help120

Technical User
Apr 15, 2001
198
US
Is their a way to set a cookie to never expire? This is the code I've right now.

<?php
$name = &quot;nonflash&quot;;
setcookie(&quot;banner&quot;,$name,time()+1209600,&quot;/&quot;,&quot;.custommaxima.com&quot;,0);

header(&quot;Location:
?>
 
Every cookie must have an expiration. You can set a cookie without an expiration, but that means the cookie only lasts until the browser is shut down.

Currently, if you use the setcookie() function, you cannot set the expiration of the cookie to later than 2038-01-19 03:14:07. This is because the expiration parameter defines the expiration as the number of seconds since the beginning of the current Unix Epoch, and the next second after that date and time is when the largest number stored by an unsigned 32-bit integer (232-1) rolls back over to zero.

It is also possible to use the header() function to set a cookie later than that. You basically set a header that reads Set-cookie:....

For more information on the format of the set-cookie header, read here:

But let's face it, 2038 is, for all HTTP cookie intents and purposes, forever. Your site will most likely not be up until 2038, not will anyone still be using the same workstation from now until then. Want the best answers? Ask the best questions: TANSTAAFL!
 
They said Y2K would cause massive disruptions in computer systems, too.

The way I look at it, the majority of browsers in my web server logs are IE, from which I infer that a majority of users hitting my sites are running Win32.

The chances of some workstation somewhere running Win32 for 35 years without a mishap rapidly approaches zero. Want the best answers? Ask the best questions: TANSTAAFL!
 
This is true, the Y2k thing only affected one pump in the middle of Australia, no &quot;damage&quot; was caused and nothing went wrong!

Just goes to show what the press can do! --BB
 
Not to mention, cookies are a whole different idea... your saving information you either read off the system or the user entered... if the cookie expires you just have to get the information again, which you'll have code for in the case of someone getting a new computer/wiping out their cookies/etc.etc.etc.

-Rob
 
Status
Not open for further replies.

Similar threads

Replies
21
Views
403
Replies
2
Views
112
Replies
3
Views
103

Part and Inventory Search

Sponsor

Back
Top