Debian fix php session lifetime

Debian OpenLogo

Last day a friend wrote me that he had a problem with Debian your server. Exactly did not keep his sessions more than 30 minutes no matter how much is set session.gc_maxlifetime. In general, the problem is that Debian has decided to rewrite the behavior of the sessions as instead garbage collector-and a cron is started every 9th and 39th minute that clears the old sessions. Тои се намира в /etc/cron.d/php5

generally a simple script that starts / usr / lib / php5 / maxlifetime and contains the variable how long the life of the cookie is 1440 seconds or 24 minutes 😉 From now on there are 2 option or to stop the cron and thus stop the automatic cleaning which can later be reconfigured by php.ini or directly in the script to change the lifespan of the sessions with the variable max. I personally prefer the second option. It is much cleaner in general but there is a drawback – if the file is overwritten, our changes will be lost, which is an unpleasant fact.

ps. Now that you think about it, if you define another place to store your information via php itself, it should go beyond the scope of the script and thus be used again in a normal session without interrupting it roughly..

ini_set('session.gc_maxlifetime', 14400);
 ini_set('session.gc_probability', 1);
 ini_set('session.gc_divisor', 100);
 session_save_path(APP_PARENT_DIR . '/sessions');

Enhanced by Zemanta


    1. Всичко зависи от настройките на OS-a на, shared hosting you should have an option to set up php-ins that there the pork is different depending on what the hosting is managed. For the VPS, you need to see how the php is set up. This is generally for Debian guys

Leave a Reply

Your email address will not be published.

Anti SPAM *