br3nn4n Posted November 24, 2008 Share Posted November 24, 2008 I can't for the life of me get my script to keep the session alive. It is a problem because it's an article review app in which people spend some time on one page and then click save to okay the article. Well in order to use the review section you must be logged in. Often when a reviewer will click save they will be prompted to re-login. I have a session_start at the beginning of every page requiring that a user be logged in. It will randomly just delete the session. Any tips? I can post code later, I'm on my phone right now. Link to comment https://forums.phpfreaks.com/topic/133974-cannot-get-session-to-stay-alive/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 24, 2008 Share Posted November 24, 2008 Session garbage collection will run and delete session data files that have been inactive longer than the session.gc_maxlifetime setting. There are two ways to make the session last longer, set session.gc_maxlifetime longer or use AJAX to periodically send http requests to a page on your server that does a session_start() to refresh that visitor's last access time on the session data file. On a shared server, in addition to setting session.gc_maxlifetime to a larger value, you will need to set session.save_path to be to a folder that is within your account's disk space. This will allow your session.gc_maxlifetime to affect only your session data files. Link to comment https://forums.phpfreaks.com/topic/133974-cannot-get-session-to-stay-alive/#findComment-697406 Share on other sites More sharing options...
br3nn4n Posted November 24, 2008 Author Share Posted November 24, 2008 Alright I'll try the session.gc_maxlifetime setting again. The ajax thing would work, great idea! One question, how do other sites do this so that people can literally stay logged in for years? I'm going to guess cookies play a part. Link to comment https://forums.phpfreaks.com/topic/133974-cannot-get-session-to-stay-alive/#findComment-697410 Share on other sites More sharing options...
PFMaBiSmAd Posted November 24, 2008 Share Posted November 24, 2008 Identifying a visitor longer than one browser session is done using cookies. Link to comment https://forums.phpfreaks.com/topic/133974-cannot-get-session-to-stay-alive/#findComment-697411 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.