Skip to content

Public Configuration Variables

JillElaine edited this page Apr 11, 2015 · 24 revisions

Below is a list of the public configuration variables and their default values. If you want to modify the default values of these variables, you may include any or all of these variables in your 'document ready' function when you call the jquery-idleTimeout script.

Note that you must include and set the redirectUrl variable to your site's logout or redirect page in the 'document ready' function. If you receive a "404 Page Not Found" at timeout, it is likely because this variable was not correctly configured.

TRANSLATE DISPLAYED TEXT

All user messages may be translated to your desired language via the configuration variables, such as the dialogTitle and dialogText.

CONFIGURATION VARIABLE SYNTAX

Syntax - variableName: variableValue

If more than one variable is listed in the 'document ready' function, you must put a comma at the end of each variableName: variableValue pair except the last pair in the list.

Example - 'Document Ready' Multiple Variables

  $(document).ready(function () {
    $(document).idleTimeout({
      redirectUrl:  '/logout',      // trailing comma
      idleTimeLimit: 1200,          // trailing comma
      sessionKeepAliveTimer: false  // NO trailing comma - last one in the list
    });
  });

String variable values (such as all text displayed to the user, activityEvents and redirectUrl) must be enclosed within single quotation marks.

Timer variable values are in seconds (such as idleTimeLimit) are numbers and should not be enclosed in quotation marks.

Boolean variable values (true or false) or Code variable values should not be enclosed in single quotation marks.

Please note that all variable names are case-sensitive and must be spelled correctly. If you have problems, please check for typos, spelling errors and missing commas in your runtime configuration.

DETAILS OF A FEW OF THE VARIABLES

idleCheckHeartbeat Variable

This variable controls how many seconds between 'polling' functions, such as checks for user inactivity & logouts. The default is 2 (seconds). A longer time between polls reduces overhead but will make the plugin less 'snappy'.

customCallback Variable

If you want custom function(s) to occur before user logout, user the customCallback variable. Example:

customCallback: function () {
  // define custom js function(s) here
}

activityEvents Variable

The activityEvents variable is a string of event names; each event name must be separated by one space. The default setting for activityEvents is 'click keypress scroll wheel mousewheel mousemove'. This covers most common keyboard and mouse events.

Note that the 'mousemove' event adds some overhead to the function as it fires multiple times on even small mouse movements. And some browsers may detect the 'mousemove' event even when the mouse has not moved.

You can learn more about events at Mozilla's Event Reference and whether a browser correctly detects events (or not) at Quirksmode.

LIST OF PUBLIC CONFIGURATION VARIABLES: Default Value, Type & Information

  • redirectUrl: '/logout' - String or Boolean false - redirect to this URL on logout. Set to redirectUrl: false to disable redirect
  • idleTimeLimit: 1200 - Number - 'No activity' time limit in seconds. 1200 = 20 Minutes
  • idleCheckHeartbeat: 2 - Number - Frequency to check for idle timeouts in seconds
  • customCallback: false - Boolean false or JS Code - optional custom callback to perform before logout
  • activityEvents: 'click keypress scroll wheel mousewheel mousemove' - String - separate each event with a space
  • enableDialog: true - Boolean - set to false for logout without warning dialog
  • dialogDisplayLimit: 180 - Number - Time to display the warning dialog before logout in seconds. 180 = 3 Minutes
  • dialogTitle: 'Session Expiration Warning' - String - also displays on browser title bar
  • dialogText: 'Because you have been inactive, your session is about to expire.' - String
  • dialogTimeRemaining: 'Time remaining' - String
  • dialogStayLoggedInButton: 'Stay Logged In' - String
  • dialogLogOutNowButton: 'Log Out Now' - String
  • errorAlertMessage: 'Please disable "Private Mode", or upgrade to a modern browser. Or perhaps a dependent file missing. Please see: https://github.com/marcuswestin/store.js' - String - error message if https://github.com/marcuswestin/store.js not enabled
  • sessionKeepAliveTimer: 600 - Number or Boolean false - ping the server at this interval in seconds. 600 = 10 Minutes. Set to sessionKeepAliveTimer: false to disable pings
  • sessionKeepAliveUrl: window.location.href - Code or String - set URL to ping. Does not apply if sessionKeepAliveTimer: false
Clone this wiki locally