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?

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.

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.