my requirement is bit of complicated . an user is accessing the data base using the web browser, while accessing the data base if the user is closed the active page instead of log out the session - that session needs to be log out automatically. can some one guide me how to make this ? i am used jquery - in the master page.
onbeforeunload - i am getting message leave the page or stay with this page. even i am getting this messages while login and and view the home page too.
we can find the tab/browser close event in javascript using " window. onbeforeunload " & " window. onunload " events. you just need to call the logout action from javascript by clicking on logout icon.
This is the sample code
window.onbeforeunload = function () {
return 'You want to leave?';
};
see demo here
I think its possible to send an ajax request and you can saw your server that the user closed the browser's tab.
Also this a jquery plugin called jquery.idle, which is used to identify if the user is active.
Refer this Detecting idle time in JavaScript elegantly will gives you more idea.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With