You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-20Lines changed: 33 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,23 @@
1
1
# bootstrap-session-timeout
2
2
Inspired by [jquery-sessionTimeout-bootstrap by maxfierke](https://github.com/maxfierke/jquery-sessionTimeout-bootstrap)
3
3
4
-
You can easily upgrade from jquery-sessionTimeout-bootstrap to bootstrap-session-timeout. There have been a number of major upgrades. For example, as long as the user is doing something on the page, he will never get a timeout. The original plugin launched a timeout warning dialog in a fixed amount of time regardless of user activity. See description and documentation for more information.
4
+
There have been a number of major upgrades. For example, as long as the user is doing something on the page, he will never get a timeout. The original plugin launched a timeout warning dialog in a fixed amount of time regardless of user activity. See description and documentation for more information.
5
+
6
+
You can easily upgrade from jquery-sessionTimeout-bootstrap to bootstrap-session-timeout, since the basic options have been inherited from jquery-sessionTimeout-bootstrap and have not been renamed.
5
7
6
8
## Description
7
-
After a set amount of idle time, a Bootstrap warning dialog is shown to the user with the option to either log out, or stay connected. If "Logout" button is selected, the page is redirected to a logout URL. If "Stay Connected" is selected, a keep-alive URL is requested through AJAX (optional) to keep the session alive. If no option is selected after another set amount of idle time, the page is automatically redirected to a timeout URL.
9
+
After a set amount of idle time, a Bootstrap warning dialog is shown to the user with the option to either log out, or stay connected. If "Logout" button is selected, the page is redirected to a logout URL. If "Stay Connected" is selected the dialog closes and the session is kept alive. If no option is selected after another set amount of idle time, the page is automatically redirected to a set timeout URL.
10
+
11
+
Idle time is defined as no mouse, keyboard or touch event activity registered by the browser.
8
12
9
-
Idle time is defined as no mouse, keyboard or touch event activity registered by the browser. As long as the user is active, the keep-alive URL also keeps getting pinged and the session stays alive. Optionally, you can also use this plugin as a simple lock mechanism on its own, if you have no need to keep the server-side session alive.
13
+
As long as the user is active, the (optional) keep-alive URL keeps getting pinged and the session stays alive. If you have no need to keep the server-side session alive via the keep-alive URL, you can also use this plugin as a simple lock mechanism that redirects to your lock-session or log-out URL after a set amount of idle time.
10
14
11
15
12
16
## Getting Started
13
17
14
18
1. Include `jQuery`
15
19
2. Include `bootstrap.js` and `bootstrap.css`<br>(to support the modal dialog, unless you plan on using your own callback)
16
-
3. Include `bootstrap-session-timeout.js` or `bootstrap-session-timeout.min.js`<br>(from the /dist folder)
20
+
3. Include `bootstrap-session-timeout.js` or the minified `bootstrap-session-timeout.min.js`
17
21
4. Call `$.sessionTimeout();` after document ready
18
22
19
23
@@ -26,7 +30,7 @@ Type: `String`
26
30
27
31
Default: `'Your session is about to expire.'`
28
32
29
-
Text shown to user in dialog after warning period.
33
+
This is the text shown to user via Bootstrap warning dialog after warning period.
30
34
31
35
**keepAliveUrl**
32
36
@@ -42,23 +46,31 @@ Type: `Boolean`
42
46
43
47
Default: `true`
44
48
45
-
If `true`, pings the **keepAliveUrl** if the user clicks "Stay Connected" on the Bootstrap warning dialog. If you have no server-side session timeout to worry about, feel free to set this one to `false` to prevent unnecessary network activity.
49
+
If `true`, the plugin keeps pinging the `keepAliveUrl` for as long as the user is active. The time between two pings is set by the `keepAliveInterval` option. If you have no server-side session timeout to worry about, feel free to set this one to `false` to prevent unnecessary network activity.
46
50
47
51
**keepAliveInterval**
48
52
49
53
Type: `Integer`
50
54
51
55
Default: `5000` (5 seconds)
52
56
53
-
Minimum time in milliseconds between two keep-alive pings.
57
+
Time in milliseconds between two keep-alive pings.
58
+
59
+
**ajaxData**
60
+
61
+
Type: `String`
62
+
63
+
Default: `''`
64
+
65
+
If you need to send some data via AJAX POST to your `keepAliveUrl`, you can use this option.
54
66
55
67
**redirUrl**
56
68
57
69
Type: `String`
58
70
59
71
Default: `'/timed-out'`
60
72
61
-
URL to take browser to if no action is take after warning period.
73
+
URL to take browser to if no action is take after the warning.
62
74
63
75
**logoutUrl**
64
76
@@ -82,39 +94,39 @@ Type: `Integer`
82
94
83
95
Default: `1200000` (20 minutes)
84
96
85
-
Time in milliseconds after page is opened until browser is redirected to redirUrl.
97
+
Time in milliseconds after page is opened until browser is redirected to `redirUrl`.
86
98
87
99
**ignoreUserActivity**
88
100
89
101
Type: `Boolean`
90
102
91
103
Default: `false`
92
104
93
-
If `true`, this will launch the Bootstrap warning dialog / redirect (or callback functions) in a set amounts of time regardless of user activity.
105
+
If `true`, this will launch the Bootstrap warning dialog / redirect (or callback functions) in a set amounts of time regardless of user activity. This in turn makes the plugin act much like the [jquery-sessionTimeout-bootstrap by maxfierke](https://github.com/maxfierke/jquery-sessionTimeout-bootstrap) plugin.
94
106
95
107
**onWarn**
96
108
97
109
Type: `Function` or `Boolean`
98
110
99
111
Default: `false`
100
112
101
-
Custom callback you can use instead of showing the Bootstrap warning dialog. Note that if you need the keepAlive option, you will need to include it yourself in the callback function. See Examples below.
113
+
Custom callback you can use instead of showing the Bootstrap warning dialog.
102
114
103
-
Redirect action will still occur unless you also use add the onRedir callback.
115
+
Redirect action will still occur unless you also add the `onRedir` callback.
104
116
105
117
**onRedir**
106
118
107
119
Type: `Function` or `Boolean`
108
120
109
-
Default: false
121
+
Default: `false`
110
122
111
-
Custom callback you can use instead of redirectiong the user to **redirUrl**.
123
+
Custom callback you can use instead of redirectiong the user to `redirUrl`.
112
124
113
125
## Examples
114
126
115
127
**Basic Usage**
116
128
117
-
Shows the warning dialog after one minute. The dialog is visible for another minute. If user takes no action, browser is redirected to `redirUrl`.
129
+
Shows the warning dialog after one minute. The dialog is visible for another minute. If user takes no action (interacts with the page in any way), browser is redirected to `redirUrl`. On any user action (mouse, keyboard or touch) the timeout timer is reset. Of course, you will still need to close the dialog.
118
130
119
131
```js
120
132
$.sessionTimeout({
@@ -127,9 +139,9 @@ $.sessionTimeout({
127
139
});
128
140
```
129
141
130
-
**With onWorn Callback**
142
+
**With onWarn Callback**
131
143
132
-
Shows the "Warning!" alert after one minute. If user takes no action, after one more minute the browser is redirected to `redirUrl`.
144
+
Shows the "Warning!" alert after one minute. If user takes no action (interacts with the page in any way), after one more minute the browser is redirected to `redirUrl`. On any user action (mouse, keyboard or touch) the timeout timer is reset.
133
145
134
146
```js
135
147
$.sessionTimeout({
@@ -142,9 +154,9 @@ $.sessionTimeout({
142
154
});
143
155
```
144
156
145
-
**With both onWorn and onRedir Callback**
157
+
**With both onWarn and onRedir Callback**
146
158
147
-
Console logs the "Your session will soon expire!" text after one minute. If user takes no action, after two more minutes the "Your session has expired!" alert gets shown. No redirection occurs.
159
+
Console logs the "Your session will soon expire!" text after one minute. If user takes no action (interacts with the page in any way), after two more minutes the "Your session has expired!" alert gets shown. No redirection occurs. On any user action (mouse, keyboard or touch) the timeout timer is reset.
148
160
149
161
```js
150
162
$.sessionTimeout({
@@ -163,7 +175,8 @@ $.sessionTimeout({
163
175
In lieu of a formal styleguide, take care to maintain the existing coding style. Add comments for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
164
176
165
177
## Release History
166
-
* 2012-09-10 v1.0.0 Initial release.
178
+
* 2014-01-23 v1.0.1 Added an option to sent data to the keep-alive URL.
179
+
* 2014-01-22 v1.0.0 Initial release.
167
180
168
181
## License
169
182
Copyright (c) 2014 [Orange Hill](http://www.orangehilldev.com). Licensed under the MIT license.
0 commit comments