P5system Posted March 7, 2013 Share Posted March 7, 2013 Hi< I am running a script in php I want the user logout when they close the browser? Any help will be appreciated Quote Link to comment https://forums.phpfreaks.com/topic/275348-auto-logout-after-browser-is-closed-in-php/ Share on other sites More sharing options...
teynon Posted March 7, 2013 Share Posted March 7, 2013 If your using sessions, they should expire when the browser is closed, depending on your settings. Quote Link to comment https://forums.phpfreaks.com/topic/275348-auto-logout-after-browser-is-closed-in-php/#findComment-1417121 Share on other sites More sharing options...
Shadowing Posted March 7, 2013 Share Posted March 7, 2013 If you are using cookies its impossible Quote Link to comment https://forums.phpfreaks.com/topic/275348-auto-logout-after-browser-is-closed-in-php/#findComment-1417133 Share on other sites More sharing options...
teynon Posted March 7, 2013 Share Posted March 7, 2013 (edited) Sessions use cookies. The cookie setter can specify a deletion date, in which case the cookie will be removed on that date. If the cookie setter does not specify a date, the cookie is removed once the user quits his or her browser. http://en.wikipedia.org/wiki/HTTP_cookie#Implementation Edited March 7, 2013 by teynon Quote Link to comment https://forums.phpfreaks.com/topic/275348-auto-logout-after-browser-is-closed-in-php/#findComment-1417135 Share on other sites More sharing options...
ShoeLace1291 Posted March 7, 2013 Share Posted March 7, 2013 A more clarifying statement: Sessions are a simple way to store data for individual users against a unique session ID. This can be used to persist state information between page requests. Session IDs are normally sent to the browser via session cookies and the ID is used to retrieve existing session data. The absence of an ID or session cookie lets PHP know to create a new session, and generate a new session ID. http://www.php.net/manual/en/session.examples.basic.php Quote Link to comment https://forums.phpfreaks.com/topic/275348-auto-logout-after-browser-is-closed-in-php/#findComment-1417137 Share on other sites More sharing options...
P5system Posted March 12, 2013 Author Share Posted March 12, 2013 (edited) Thank you all Edited March 12, 2013 by P5system Quote Link to comment https://forums.phpfreaks.com/topic/275348-auto-logout-after-browser-is-closed-in-php/#findComment-1418102 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.