Skip to content

ericlbarnes/jquery-idle-timeout

 
 

Repository files navigation

jQuery Idle Timeout

See the original Mint.com example, or a demo using jQuery UI's dialog widget.

This script allows you to detect when a user becomes idle (detection provided by Paul Irish's idletimer plugin) and notify the user his/her session is about to expire. Similar to the technique seen on Mint.com. Polling requests are automatically sent to the server at a configurable interval, maintaining the users session while s/he is using your application for long periods of time.

Example

Changes

  • Added an onSuccess callback
  • Changed the keepAliveUrl to return json
  • Exposed many of the private timer methods
  • Now checks your server session to find out when the last in-browser activity was; good if your users open multiple tabs.

Example Setup:

$.idleTimeout('#dialog', 'div.ui-dialog-buttonpane button:first', {
	idleAfter: 5,
	pollingInterval: 2,
	keepAliveURL: 'keepalive.php',
	serverResponseEquals: 'OK',
	onTimeout: function(){
		window.location = "timeout.htm";
	},
	onIdle: function(){
		$(this).dialog("open");
	},
	onCountdown: function(counter){
		$countdown.html(counter); // update the counter
	},
	onSucess: function(response){
		// Do whatever with response
	}
});

About

Notify your users when their sessions are about to expire.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 68.6%
  • HTML 27.3%
  • CSS 2.4%
  • PHP 1.7%