In my application i am allowing only 3 admin users at a time to log in to the application.
In case where one of the admin user directly closes the window or tab without signing out i need to invalidate the session or
need to decrement the number of admin users who has logged in.
I tried with following scenarios:
1. jQuery(window).bind("beforeunload", function(){
//loadSrc('logout');
//alert("You are about to leave the window");
firstEntry = false;
if(confirm("You are closing the window. do you want to continue. Click 'Ok' to close or click 'Cancel' to stay back")){
loadSrc('logout');
return;
}else{
loadSrc('appsListing');
return;
}
//loadSrc('logout');
});
2. onunload attribute in body tag and called the function loadSrc('logout').
Both of the above solutions failed to work when there are multiple tabs opened in the browser. But either of the above solution is working properly when the user closes the tab and not window.