anu123 Posted December 18, 2009 Share Posted December 18, 2009 Hii Can anyone tell me how to override the default session duration and set a session time duration of our own? Any idea? Thank you in advance Quote Link to comment https://forums.phpfreaks.com/topic/185560-setting-session-time-duration/ Share on other sites More sharing options...
teamatomic Posted December 18, 2009 Share Posted December 18, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/185560-setting-session-time-duration/#findComment-979658 Share on other sites More sharing options...
anu123 Posted January 4, 2010 Author Share Posted January 4, 2010 I set the session duration as mentioned, but it is still taking the default 24 mins as the session expiration time. Help please Quote Link to comment https://forums.phpfreaks.com/topic/185560-setting-session-time-duration/#findComment-988094 Share on other sites More sharing options...
PFMaBiSmAd Posted January 4, 2010 Share Posted January 4, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/185560-setting-session-time-duration/#findComment-988144 Share on other sites More sharing options...
anu123 Posted January 5, 2010 Author Share Posted January 5, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/185560-setting-session-time-duration/#findComment-988826 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.