This time I will share jQuery Plugin and tutorial about Session Timeout Alert Plugin With jQuery – userTimeout, hope it will help you in programming stack.
Yet another jQuery session timeout and keep-alive control that checks the user activities and shows an alert modal dialog asking your users if they want to stay connected or to log off after a specified idle time. If log off is clicked, the webpage is redirected to a logout URL you specify.
How to use it:
1. Include jQuery library and the jQuery userTimeout plugin on the webpage.
1 |
< script src = "//code.jquery.com/jquery-1.12.1.min.js" ></ script > |
2 |
< script src = "dist/jquery.userTimeout.js" ></ script > |
2. Include jQuery UI or Bootstrap framework on the webpage. In this case, we use Bootstrap’s modal component for the session timeout alert dialog.
1 |
< link rel = "stylesheet" href = "bootstrap.min.css" > |
2 |
< script src = "bootstrap.min.js" ></ script > |
3. Initialize the plugin as follows. The plugin will displays a Bootstrap based session timeout modal after 3000ms (3 seconds).
1 |
$(document).userTimeout({ |
4. Customize the plugin. Here’re default plugin settings which can be passed as an object during init.
01 |
$(document).userTimeout({ |
31 |
modalTitle: 'Session Timeout' , |
34 |
modalBody: 'You're being timed out due to inactivity. Please choose to stay signed in or to logoff. Otherwise, you will logged off automatically.' , |
37 |
modalLogOffBtn: 'Log Off' , |
40 |
modalStayLoggedBtn: 'Stay Logged In' |
Change log:
v0.3.0 (2016-05-14)
- Cleaned up some of the code
- Fixed a few minor bugs
- Added comments to the functions
- Added support for console errors if debugging is off
- Included focus as a document event
This awesome jQuery plugin is developed by lleblanc42. For more Advanced Usages, please check the demo page or visit the official website.