Jump to content

How to logout when a tab in browser is closed?


Festy

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.