PHP Dates End In A Few Minutes

We have a PHP application (SilverStripe) on cPanel LAMP sharing server. CMS user loses session every couple of minutes. The following are the session settings based on phpinfo() on the hosting platform:

 session.gc_maxlifetime = 0 session.gc_divisor = 100 session.gc_probability = 1 session.save_handler = files session.save_path = /tmp session.cookie_lifetime = 0 

PHP code lacks session management. In fact, SilverStripe CMS actually pings the server every 5 minutes to keep the session active, but timeouts happen earlier.

What could be the reason for this?

+4
source share
3 answers

Check php.ini, the value set for session.gc_maxlifetime is the identifier lifetime in seconds.

I believe the default is 1440 seconds (24 minutes)

http://www.php.net/manual/en/session.configuration.php

Edit: As some comments have noted, the above is not entirely accurate. A great explanation of why and how to implement session time is available here:

+1
source

The CPANEL-12629 internal register is open to fix the problem with / scripts / clean _user_php_sessions, where sessions older than 24 minutes are always deleted on systems running EasyApache 3 (despite setting user-defined values ​​for session.gc_maxlifetime). I am updating this thread with additional information about the status of this case as it becomes available. In the meantime, a temporary workaround is to edit the following file:

the code:

 /usr/local/cpanel/scripts/clean_user_php_sessions Within the file, change this entry: 

the code:

else {my $ dirs = Cpanel :: PHPINI :: get_directives (['session.save_path', 'session.max_lifetime'], 1, '/ usr / local / lib'); clean_sessions ($ dirs β†’ {'session.save_path'} {'value'}, $ dirs β†’ {'sessions.max_lifetime'} {'value'}); }

return 1;

To:

the code:

else {my $ dirs = Cpanel :: PHPINI :: get_directives (['session.save_path', 'session.gc_maxlifetime'], 1, '/ usr / local / lib'); clean_sessions ($ dirs β†’ {'session.save_path'} {'value'}, $ dirs β†’ {'session.gc_maxlifetime'} {'value'}); }

return 1;

Then exclude this file from cPanel updates with the following command:

the code:

 echo '/usr/local/cpanel/scripts/clean_user_php_sessions' >> /etc/cpanelsync.exclude 

Remember to edit "/etc/cpanelsync.exclude" to remove this line as soon as we pulled the update to solve the problem.

Source: https://forums.cpanel.net/threads/php-session-timeout-since-64-0-update.598247/

+1
source

It does not appear in the documentation, but setting session.gc_maxlifetime to 0 means that the session will not expire until the browser is closed.

Of course, this still does not fix the problems associated with the garbage collector doing it on its own. The best solution for this is still changing session.save_path

0
source

All Articles