Reputation: 45757
How do I set up a cookie that won't never expire, even when the user closes his browser or stops his machine?
Thanks!
Upvotes: 2
Views: 17703
Reputation: 5136
The user will always have the option to remove or block cookies. But you can always set the expire date in the far future.
Upvotes: 0
Reputation:
You can assign a expiration date which is very far from now:
setcookie("testCookie","value",mktime (0, 0, 0, 12, 31, 2015));
//Expires on 31 december 2015
Upvotes: 2
Reputation: 11175
setcookie("example", $cookievalue, time()+60*60*24*6004, "/", ".example.com");
Impossible to set a cookie forever, browsers wouldn't allow that. (ps. it's amazing what wonders google will conjure up if you were to literally google the title of this question)
Upvotes: 2
Reputation: 28187
I don't think there is a way to have a 'permanent' cookie, but rather one that expires very very far into the future. Just because you remained logged into a website/service the next time you return or after you close your browser, does not mean that there is no expiration date on the cookie.
Check out the PHP documentation on setting the lifetime of a cookie.
Upvotes: 5