autoLogOut.js is small utility javascript, which helps us to manage the auto-logout state in multiple tabs if the user is not active. This relies on localstorage and localstorage change event for synchronizing the setTimeout between tabs.
autoLogOut.js implements the event listener on following events:-
- Document ready
- Document unload
- Mouse movement
- Scroll event
- Window resize
- Storage change
For implementation:
var signOut = autoLogOut.init({ timeout: 1, sessionKey: 'Key', debug: true});
signOut.onSignOut = function () {
alert("Called Timeout");
console.log("Timeout Called");
};
autoLogOut.init() function take intial configuration object, each key description mentioned below:-
- timeout: number of minutes after that session will auto logout
- sessionKey: name of the localstorage key
- debug: console.log on event and timeout registration.
autoLogOut.js have three methods:-
- init : initial configuration function
- signOut: manual call the onSignOut callback
- onSignOut: this callback callback on logout
Related Content:- - https://stackoverflow.com/questions/28230845/communication-between-tabs-or-windows