Jump to content

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?

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.