Cookies that don't expire?
Moderator: General Moderators
-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany
Cookies that don't expire?
Hi guys,
I used the search but couldn't find anything that helps me.
Is there a way to set a cookie that doesnt expire? Can I just set the expiration-time to a trillion seconds or something to keep it as long as possible? How long a period can a cookie be set for at max?
Thx,
Steff
I used the search but couldn't find anything that helps me.
Is there a way to set a cookie that doesnt expire? Can I just set the expiration-time to a trillion seconds or something to keep it as long as possible? How long a period can a cookie be set for at max?
Thx,
Steff
-
Beans
- Forum Commoner
- Posts: 49
- Joined: Mon Dec 23, 2002 3:06 am
- Location: Manila, Philippines
- Contact:
I'll have to agree with mchaggis...
My version is, set it to today's date plus 365 day. Then everytime they visit the site, set the cookie to that. This will add another year to the cookie from the date that they accessed the site.
Of course, that is assuming that they will actually visit your site more than once a year.
My version is, set it to today's date plus 365 day. Then everytime they visit the site, set the cookie to that. This will add another year to the cookie from the date that they accessed the site.
Of course, that is assuming that they will actually visit your site more than once a year.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany
-
sleepingdanny
- Forum Newbie
- Posts: 12
- Joined: Thu Mar 20, 2003 4:27 am
- Location: Israel
Yu can try
Just so you'll know "time()+3600" = 1 Hour...
Code: Select all
<?
setcookie("CookieName") #without using "time()+"
?>Code: Select all
<?
setcookie("CookieName",time()+3600);
?>- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
If you don't set the time argument for setcookie() then the cookie will expire when the browser is closed:
and then use $expire_date as the argument for expiry time.
Mac
To have a cookie that'll expire in the far distant future use mktime() to do something like:PHP manual - setcookie() wrote:If [time is] not set, the cookie will expire at the end of the session (when the browser closes).
Code: Select all
$expire_date = mktime(0, 0, 0, 1, 1, 2037);Mac
Last edited by twigletmac on Wed Mar 26, 2003 11:14 am, edited 1 time in total.
-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany