ArizonaJohn Posted June 3, 2009 Share Posted June 3, 2009 Hi, I'm using session cookies and they work great at first. But if I have a page pulled up for about 45 minutes, the session cookies seem to die, even if I don't open up any other websites. Are there measures that I could take to make my session cookies last longer? Thanks, John Link to comment https://forums.phpfreaks.com/topic/160730-solved-session-cookies-not-lasting-very-long/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 3, 2009 Share Posted June 3, 2009 The session cookie will exist as long as at least one instance or tab of the browser is kept open. It is more likely that the session data file is being deleted on the server. On busy web servers, the session garbage collection runs frequently and deletes any session data files that have a last access time older than the session garbage collection maximum lifetime. Are you on a shared web server? Link to comment https://forums.phpfreaks.com/topic/160730-solved-session-cookies-not-lasting-very-long/#findComment-848267 Share on other sites More sharing options...
ArizonaJohn Posted June 3, 2009 Author Share Posted June 3, 2009 I think I am. Network Solutions. Should I ask them to give me longer sessions? I'm hoping to not have to spend more money for a dedicated server. Link to comment https://forums.phpfreaks.com/topic/160730-solved-session-cookies-not-lasting-very-long/#findComment-848278 Share on other sites More sharing options...
PFMaBiSmAd Posted June 3, 2009 Share Posted June 3, 2009 In order to set a longer session.gc_maxlifetime, you will first need to set session.save_path to be to a private folder within your account's folder tree. This is so that when garbage collection runs, it only operates on your session data files and uses your session.gc_maxlifetime setting. If possible, set session.save_path to be to a folder that is outside of your document root folder (closer to the disk root folder.) If that option is not available you will need to set it to a folder within your document root folder. In this case, you should also put a .htaccess file in the folder that prevents all http/https access to the files in the folder. Both session.save_path and session.gc_maxlifetime must be set before every session_start() statement. It is best to put these settings into a .htaccess file (when php is running as an Apache module) or in a local php.ini file (when php is running as a CGI application.) If neither of those options are available you can set them in your script but they must be set before every session_start() statement. Link to comment https://forums.phpfreaks.com/topic/160730-solved-session-cookies-not-lasting-very-long/#findComment-848289 Share on other sites More sharing options...
ArizonaJohn Posted June 3, 2009 Author Share Posted June 3, 2009 Thanks, I'm trying to implement your suggestions. Link to comment https://forums.phpfreaks.com/topic/160730-solved-session-cookies-not-lasting-very-long/#findComment-848354 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.