Skip to content
Advertisement

PHP session expiring too early

I have an issue, my apps sessions are expiring unexpectedly after about 15 minutes. I need them to expire after 4 hours.

The server is Centos 5.5, PHP is 5.3.2.

Below is my code (included in an global header).

JavaScript

My .htaccess file contains:

JavaScript

Any help or insight would be greatful.

EDIT: I was unable to login when i updated my .htaccess file, the session wasn’t starting. So I have now removed:

JavaScript

which now allows me to login.

Advertisement

Answer

On initial examination, I’d lower your gc_maxlifetime and cookie_lifetime settings. I suspect that 14400000 is a little high for PHP to cope with (in theory, a 32-bit OS should be able to go up to 2147483647, but this could still be a factor).

If you only need 4 hours of lifetime, then 14400 would be a perfect setting, and may resolve your problem for the reason mentioned above.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement