jayteepics Posted August 23, 2011 Share Posted August 23, 2011 This problem happens in both IE9 and Chrome 13.0.782.112 m on Windows If I close the browser down, my session data is gone on browser restart, if however I just close the tab leaving other tabs say with BBC news and restart my app in a new tab, both browsers remember the old session data. Since the intended user could do this at any time before completing a transaction, I don't actually get a chance to destroy the session this only happens if they complete payment for their order via.. session_destroy(); $conn->commit(); $conn->autocommit(TRUE); In an attempt to clean up I tried various combinations at the top of the start page "index.php".. session_start(); // $_SESSION = array(); session_destroy($_SESSION['cart']); session_destroy($_SESSION['address']); // $_SESSION['cart'] = array(); // $_SESSION['address'] = array(); // session_destroy(); Can anyone please shed any light on this behaviour difference? Jamie Quote Link to comment https://forums.phpfreaks.com/topic/245503-browser-and-_session-data-now-i-remember-it-now-i-dont-behavior/ Share on other sites More sharing options...
xyph Posted August 23, 2011 Share Posted August 23, 2011 It's browser behavior. When a cookie is created with no expire time, the browser should expire it when the window is closed. From what I can tell, the behavior of most browsers is to not see a tab being closed as a trigger to expire that cookie. There's no real way to end a session when a tab closes without relying on JavaScript. Quote Link to comment https://forums.phpfreaks.com/topic/245503-browser-and-_session-data-now-i-remember-it-now-i-dont-behavior/#findComment-1260960 Share on other sites More sharing options...
jayteepics Posted August 23, 2011 Author Share Posted August 23, 2011 Thanks for that xyph. So is there no PHP way to clean up past $_SESSION data and start again when they return to the site in a new tab? Quote Link to comment https://forums.phpfreaks.com/topic/245503-browser-and-_session-data-now-i-remember-it-now-i-dont-behavior/#findComment-1260965 Share on other sites More sharing options...
xyph Posted August 23, 2011 Share Posted August 23, 2011 As far as PHP is concerned, the tab was never closed. Quote Link to comment https://forums.phpfreaks.com/topic/245503-browser-and-_session-data-now-i-remember-it-now-i-dont-behavior/#findComment-1260966 Share on other sites More sharing options...
jayteepics Posted August 23, 2011 Author Share Posted August 23, 2011 Cool ;-)))))) Quote Link to comment https://forums.phpfreaks.com/topic/245503-browser-and-_session-data-now-i-remember-it-now-i-dont-behavior/#findComment-1260970 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.