robcrozier Posted February 23, 2009 Share Posted February 23, 2009 Hi. I'm having an issue with my file uploading script. Basically, it uses perl to do the actual uploading which means massive files can be uploaded. This, however causes my PHP session to timeout and log the user out before they have a chance to do anything with their newly uploaded file. Is there any way that i can make sure that the session does not timeout on this one script? I want the session timeout to remain at around 20 mins as default, except when the user uploads a file that may take more than 20 mins depending on the size of it. Any suggestions would be great! Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/146497-session-timeout-issue/ Share on other sites More sharing options...
wrathican Posted February 23, 2009 Share Posted February 23, 2009 look at setting the php.ini session length property at the top of your script Quote Link to comment https://forums.phpfreaks.com/topic/146497-session-timeout-issue/#findComment-769080 Share on other sites More sharing options...
robcrozier Posted February 23, 2009 Author Share Posted February 23, 2009 If i set this at the top of the script to say 3hours or something, and then reset it to 20mins at the bottom of the script, after the file(s) have been uploaded, can anyone foresee any problems? Cheers Quote Link to comment https://forums.phpfreaks.com/topic/146497-session-timeout-issue/#findComment-769085 Share on other sites More sharing options...
PFMaBiSmAd Posted February 23, 2009 Share Posted February 23, 2009 Won't work. Any session data file that is older than the current session.gc_maxlifetime setting will be deleted when garbage collection runs. As soon as you set it to the shorter value and a session_start() causes garbage collection to run, any session data file older than the current shorter setting will be deleted. Also, on a shared web server when you use the default session save path, the shortest session.gc_maxlifetime setting of all the scripts running on the server wins, so you must also set the session.save_path setting to be to a private folder within your account's storage space so that your session.gc_maxlifetime setting only affects your session data files. A session is just a container that holds variables. You should not rely on the operation of the session or session garbage collection to log anyone out. You should set the session.gc_maxlifetime setting to be as long as you need it and any automatic log out should rely on you storing the last access time for each visitor and then checking if that last access time is greater in the past than a limit you set. If someone is uploading a file, you would simply use a longer limit in your comparison. Quote Link to comment https://forums.phpfreaks.com/topic/146497-session-timeout-issue/#findComment-769090 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.