View Full Version : setcooking(), expires never - how?

09-28-2006, 01:29 PM
How would you make cookies to never expire? If you set it to 0 it will destroy after the session is gone. And negative values don't work?

09-28-2006, 02:16 PM
setcookie ("TestCookie", "", time() + 60*60*24*365*100);

will make the cookie expire after 100 years.

09-28-2006, 02:26 PM
I set my cookie to expire in one year. Thanks for reply, I were looking for unlimited expiration, but seems it's impossible. Anyways, most browsers would have deleted the old cookies anyway...

09-28-2006, 02:32 PM
"unlimited expiration" as such is, afaik, not possible and probably not usefull. but you can achieve the same by setting the expirationdate unrealistically far in the future.

09-28-2006, 03:29 PM
There is no guarantee that the cookie won't expire after the user ends his session. He may have just set them to expire anyway (usefull for public computers).

09-29-2006, 07:30 AM
there's even no guarantee that the cookie will ever be realy set because he can adjust his clock and set it a few years in the future... or he can just refuse cookies altogether...

09-29-2006, 10:26 AM
reguler cookie deleters do exist :P

09-29-2006, 11:40 AM
You can check if an user accepts cookies by checking if it's set on the next page. You just have no guarantee that they will be set as long as you want.

09-29-2006, 11:49 AM
i think this thread is getting a bit silly.

the answer to the original question is long reached --> you can only set the expiredate way in the future.

09-29-2006, 11:54 AM
You're right. No reason I should care if nobody else does.