How to Check If User Has Logged Out From Other Tab

In Facebook if you are using multiple tabs and logout from any of the tabs, other tab show a popup alert, “you have logged out. Please login again.” What if you want to implement this kind of thing. One of my readers asked me to write an article on this.

Session Check AJax php

To implement this, you can use ajax calls and implement setInterval() method of js to keep checking the session.

First create a php file which returns the status of the session.

sessioncheck.php

Now create a jQuery function to create ajax call and popup a message if user has logged out.

Now call this JavaScript function in every 5 or 10 seconds to keep checking sessions. I am using 5 seconds time interval

 Demo

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest updates, web design resources and tools.

You have Successfully Subscribed!

About The Author

  • ADD YOUR COMMENT

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Receive fresh web design resources and SEO tips in your email by our weekly newsletter

You have Successfully Subscribed!

Pin It on Pinterest

Share This

Share This

Share this post with your friends!