PHP Session ID - how long is a SID valid?

cookies, lifetime, php, session, timeout

Solution

In theory you can store it as long as you want, but you will be needlessly using up resources. The default is 20 minutes and can be adjusted in `php.ini` by setting the `session.gc_maxlifetime` parameter. If you need to persist data for longer than that, it would make sense to put it into a database rather than the session.

Problem

Theoretically, if a PHP session ID is stored in a cookie that has a lifetime of 365 days, will the session ID resume the right session data on day 365 or will the related session data be timed out/deleted due to the session lifetime settings? And how long can/should I store and use a session ID?

Original source

Related problems