vinodxx Posted May 8, 2009 Share Posted May 8, 2009 Suppose there is a variable is storied in a session variable $_SESSION['record']. And internet connection goes and comes again. This happens with unreliable ISPs. How to preserve the old value of $_SESSION['record'] in the new situation. Link to comment https://forums.phpfreaks.com/topic/157357-how-to-preserve-php-session-variables-when-there-is-a-glitch-in-net-connection/ Share on other sites More sharing options...
w3evolutions Posted May 8, 2009 Share Posted May 8, 2009 You can add: ?PHPSESSID=<?=session_id() ;?> to all of the URLS on the site. This way if an ISP drops and the user clicks on the page they will be passing back the same SSID. You can store it in a cookie and reset the ssid. Link to comment https://forums.phpfreaks.com/topic/157357-how-to-preserve-php-session-variables-when-there-is-a-glitch-in-net-connection/#findComment-829417 Share on other sites More sharing options...
premiso Posted May 8, 2009 Share Posted May 8, 2009 And internet connection goes and comes again. As long as sessions are setup to use cookies and the sure does not close the browser this should not be an issue. The other route is to session_set_cookie_params make the cookie last longer than the browser close, that should re-instantiate the session upon going back to your site. Link to comment https://forums.phpfreaks.com/topic/157357-how-to-preserve-php-session-variables-when-there-is-a-glitch-in-net-connection/#findComment-829420 Share on other sites More sharing options...
JonnoTheDev Posted May 8, 2009 Share Posted May 8, 2009 Hmm never had this before. If the users web browser is still open and the connection drops and then reconnects it's a possibility that the session will still be active however I have never tested this so you would have to try by switching your router off. You could keep the value active also by storing the data in a cookie and transferring to a session var if detected. Link to comment https://forums.phpfreaks.com/topic/157357-how-to-preserve-php-session-variables-when-there-is-a-glitch-in-net-connection/#findComment-829424 Share on other sites More sharing options...
allworknoplay Posted May 8, 2009 Share Posted May 8, 2009 This is a curious question because session data is stored at the server side. I think the default is 20 mins. So as long as the user doesn't close the browser, I can't see why intermittent connections would cause the user to lose his session when his internet comes back? As long as it's within 20 mins.... Link to comment https://forums.phpfreaks.com/topic/157357-how-to-preserve-php-session-variables-when-there-is-a-glitch-in-net-connection/#findComment-829448 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.