Re: Changing Session Timeout

From: Date: Fri, 27 Apr 2007 16:29:44 +0000
Subject: Re: Changing Session Timeout
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-253992@lists.php.net to get a copy of this message
On 4/27/07, Aaron Axelsen <lists@frozenpc.net> wrote:
I now have the following settings: session_name('myapp'); $mytimeout = 180 * 60; // minutes * 60 session_set_cookie_params($mytimeout); $sessdir = ini_get('session.save_path')."/myapp"; if (!is_dir($sessdir)) { mkdir($sessdir, 0777); } ini_set('session.save_path', $sessdir); // New Attempt session_cache_limiter(); session_cache_expire($mytimeout / 60); ini_set('session.gc_maxlifetime', $mytimeout / 60); #ini_set('session.gc_probability',1); #ini_set('session.gc_divisor',1); session_start(); I logged in and then left the computer untouched for an hour. When I came back the session was timed out, and I was required to login. Something still isn't working right. Any ideas? I have checked the settings using phpinfo() and confirmed that the values are in fact being set by the above commands. -- Aaron
My mistake, gc_maxlifetime is in seconds, i meant to say that, but i said it was in minutes :) if you change this: ini_set('session.gc_maxlifetime', $mytimeout / 60); back to ini_set('session.gc_maxlifetime', $mytimeout); It will work i guess :) Tijnema
Tijnema ! wrote: On 4/27/07, Aaron Axelsen <lists@frozenpc.net> wrote:
I am trying to change my session timeout to 180 minutes, and everything ive tried has not worked. Does anyone have any idea why this isn't working properly? I currently am trying to set the following: session_name('myapp'); $mytimeout = 180 * 60; // minutes * 60 session_set_cookie_params($mytimeout); $sessdir = ini_get('session.save_path')."/myapp"; if (!is_dir($sessdir)) { mkdir($sessdir, 0777); } ini_set('session.save_path', $sessdir); session_cache_limiter(); session_cache_expire($mytimeout); ini_set('session.gc_maxlifetime', $mytimeout); #ini_set('session.gc_probability',1); #ini_set('session.gc_divisor',1); session_start(); -- Aaron Axelsen lists@frozenpc.net
session_set_cookie_params requires the number given in seconds, which you did correct. But session_cache_expire requires the number given in minutes. and session.gc_maxlifetime is in minutes again. So that is correct too. you could try replace this: session_cache_expire($mytimeout); with: session_cache_expire($mytimeout / 60); That should fix it, if not, just come back, but then tell us what exactly is wrong, does the session timeout too early? does the session timeout too late? does the session timeout never? Tijnema -- Aaron Axelsen lists@frozenpc.net Great hosting, low prices. Modevia Web Services LLC -- http://www.modevia.com


« previous php.general (#253992) next »