Festy Posted February 9, 2008 Share Posted February 9, 2008 Hello guys, I'm working on a professional social networking community site and I want to achieve the following tasks in an efficient manner : 1. If a user is logged in, and he closes his tab in the browser and reopens it, he should be logged out when he types the url of the site. 2. If a user is logged in, and he closes his browser, he should be logged out when he types the url of the site. I know second one is not a problem, but still I'd like to know how other advanced/expert php programmer do this. Can anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/90180-how-to-logout-when-a-tab-in-browser-is-closed/ Share on other sites More sharing options...
revraz Posted February 9, 2008 Share Posted February 9, 2008 Well the 2nd is automatic. For the first, you probably need to use javascript and detect when the window closes. If JS is disabled, I am not sure how you can do it. Quote Link to comment https://forums.phpfreaks.com/topic/90180-how-to-logout-when-a-tab-in-browser-is-closed/#findComment-462414 Share on other sites More sharing options...
Northern Flame Posted February 9, 2008 Share Posted February 9, 2008 might need AJAX, i myself do not know AJAX but I know people that have done something similar to this via AJAX Quote Link to comment https://forums.phpfreaks.com/topic/90180-how-to-logout-when-a-tab-in-browser-is-closed/#findComment-462422 Share on other sites More sharing options...
btherl Posted February 9, 2008 Share Posted February 9, 2008 If there is a single tab, then you can use a solution like this The above method is for making a popup on exit of a site, but the same principle can be used to log the user out on exit. It's not 100% reliable, and will definitely fail if the user opens multiple tabs on your site. I know this isn't an answer to your question, but if you look at all the major social networking sites, none of them log the user out on closing of a tab. It's just not practical. Instead they use user-configurable timeouts (or fixed timeouts), as well as the standard of having cookies expire when the browser closes. Quote Link to comment https://forums.phpfreaks.com/topic/90180-how-to-logout-when-a-tab-in-browser-is-closed/#findComment-462427 Share on other sites More sharing options...
Festy Posted February 9, 2008 Author Share Posted February 9, 2008 I know this isn't an answer to your question, but if you look at all the major social networking sites, none of them log the user out on closing of a tab. It's just not practical. Instead they use user-configurable timeouts (or fixed timeouts), as well as the standard of having cookies expire when the browser closes. I completely agree with you here. I myself don't see any sense in that. But my client wants me to do that and I don't have any idea why? but if it can be achieved somehow then it's ok otherwise I'll have to discuss this issue with him. Quote Link to comment https://forums.phpfreaks.com/topic/90180-how-to-logout-when-a-tab-in-browser-is-closed/#findComment-462433 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.