Maximum Cookie Lifetime?

First off, I hope this is in the right area.

I'm writing a PHP script at the moment for a simple site which incorporates cookie-based logins. There is a "permanent login" function, for which a cookie is set, with a long lifetime.

My question is: is there a maximum lifetime for a cookie, and if so what is it?

If anyone knows the answer to this I'd be very grateful. I have tried 365 days so far, and that works fine.


Who is Participating?
seanpowellConnect With a Mentor Commented:
January 19, 2038

This is caused by an overflow of the time_t variable in the C/C++ programming language. This variable is a 32-bit integer value used as an offset in seconds from January 1, 1970. This variable has a maximum value of 2147483647, which only allows dates through 3:14:07 GMT on January 19, 2038.
mattfairwConnect With a Mentor Commented:
Cookies stay on the users system until either:

A. they delte it
B. You delete it / Change its contents

So maximum life can be anything theoretically...but that may not always be the case
BigglesZXAuthor Commented:
Thanks chaps :-). Split points 'cos you both had good answers.


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.