Skip to content

Latest commit

 

History

History
42 lines (37 loc) · 1.52 KB

README.md

File metadata and controls

42 lines (37 loc) · 1.52 KB

autoLogOut.js

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:-

  1. Document ready
  2. Document unload
  3. Mouse movement
  4. Scroll event
  5. Window resize
  6. Storage change
All events are throttle with setTimeout approach, except 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