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.



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