简体   繁体   中英

Debugging and resolving early session timeout

About a year ago, my PHP sessions started timing out - logging clients out of the website. After some reading, I found the suggestion to increase session timeouts which I did in php.ini

session.cookie_lifetime=14400
session.gc_maxlifetime=14400

Yet, my session continues to timeout after about 60 minutes.

I tried a second option from php.net: https://www.php.net/manual/en/function.session-start.php

session_start(['cookie_lifetime' => 14400]);

And still cant get the session to last longer than an hour...

I'm running out of places to check?

PHP Version: 5.6

Finally found the answer - after days, weeks, months of testing and trialling these settings, nothing ever seemed to work ... until I came across this comment on this thread: How do I expire a PHP session after 30 minutes?

Please note that at least two settings are crucial to setting the session time, and maybe three. The two certainly crucial ones are session.gc_maxlifetime and session.cookie_lifetime (where 0 is not the same as some long number). For complete, 100% certainty of allowing long times, it may also be necessary to set the session.save_path, due to varying OS-controled cleanup time on the /tmp directory where session files get stored by default. – @Kzqai Apr 7 '11 at 8:04

I manually set a session.save_path and oila! My sessions are now lasting 2+ hours at last check

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM