Jump to content

Setting session time duration


anu123

Recommended Posts

ini_set('session.gc_maxlifetime',1800);// 30 minutes //30*60 seconds

ini_set('session.gc_probability',1);// this and #3 set the probability of garbage collection to 100%

ini_set('session.gc_divisor',1); //#3

session_start();

 

 

HTH

Teamatomic

  • 3 weeks later...

If you are on shared web hosting and are using the default/common session.save_path setting, the shortest session.gc_maxlifetime of all the scripts running on the server will 'win' and you must set the session.save_path to point to a 'private' folder within your account's folder tree so that your session settings apply only to your session data files. The session.save_path and session.gc_maxlifetime settings must be set before every session_start() statement so it is best to globally set them in a .htaccess file (when php is running as an Apache Module) or in a local php.ini (when php is running as a CGI application.) Check that the settings are actually set correctly using a phpinfo(); statement.

 

Changing session.gc_probability and session.gc_divisor to 1 will cause a directory scan of all the session data files on every session_start() statement and should not be done on a site that has a lot of active session data files.

I tried changing the save_path.Still my session is getting expired off. Is there anything i left out.This is what i did.

$cookie_path = "/";

$cookie_timeout = 16 * 60 * 60; // in seconds

$garbage_timeout = $cookie_timeout + 600;

ini_set('session.gc_maxlifetime', $garbage_timeout);

strstr(strtoupper(substr($_SERVER["OS"], 0, 3)), "WIN") ?

$sep = "\\" : $sep = "/";

$sessdir = ini_get('session.save_path').$sep."new_sessions";

if (!is_dir($sessdir)) { mkdir($sessdir, 0777); }

ini_set('session.save_path', $sessdir);

 

session_start();

 

Any idea?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.