kcp4911 Posted March 24, 2010 Share Posted March 24, 2010 Hello. I have a couple of different scripts that incorporate storing session data into a mysql table. let me use an example... I have a simple message board. When making a comment I store the user id, the thread id, the comment, the ip address and a timestamp in a table. Obviously the record is given an id as well. Now, this works nicely 99% of the time. However, one user could make 5 different comments on the board in one session. Four of those comments would be recorded perfectly - but the other one would record everything except the user id (which is stored in a session). What could make this happen? is it a server issue? Is it a mysql issue? Is it a php issue? I am inclined to think it is a server issue. Thanks for having a think about it. simon Quote Link to comment https://forums.phpfreaks.com/topic/196348-random-session-data-not-being-inserted-into-table/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 24, 2010 Share Posted March 24, 2010 You have two apparent problems - 1) Your form processing code is not checking if the current visitor that submitted data to the form processing code is logged in, and 2) Your sessions are ending while a visitor is entering information in the form. The fix for item #1 is obvious. The fix for item #2 is to set session.gc_maxlifetime to a longer value and if you are on shared web hosting and are using the default session.save_path setting you will also need to set the session.save_path setting to be to a folder within your account's folder tree so that only your session settings apply to your sessions. All session settings just mentioned need to be set before every session_start() statement, so it is best to globally set them in the master php.ini (when you have access to it), in a local php.ini (when php is running as a CGI application), in a .htaccess file (when php is running as an Apache Module), or in your script. Quote Link to comment https://forums.phpfreaks.com/topic/196348-random-session-data-not-being-inserted-into-table/#findComment-1030991 Share on other sites More sharing options...
kcp4911 Posted March 24, 2010 Author Share Posted March 24, 2010 OK - thanks PFMaBiSmAd. I will look into those suggestions and report back. cheers Quote Link to comment https://forums.phpfreaks.com/topic/196348-random-session-data-not-being-inserted-into-table/#findComment-1030993 Share on other sites More sharing options...
PFMaBiSmAd Posted March 24, 2010 Share Posted March 24, 2010 Also, fix #2 will take care of the case where someone on a shared web server has intentionally used a short session.gc_maxlifetime (in a misguided attempt to log people out after a short period of inactivity) and it is randomly causing the sessions for your visitors to be deleted. Quote Link to comment https://forums.phpfreaks.com/topic/196348-random-session-data-not-being-inserted-into-table/#findComment-1030999 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.