Redirect user after 60 seconds of inactivity?

How can I use JavaScript on my site to redirect the user to the page / logout after 60 seconds of inactivity?

Setting the timer is simple I know: but I just want to redirect inactive users, and not break the session.

Is this possible with JavaScript?

+7
source share
2 answers

I believe you are looking for something like this:
http://paulirish.com/2009/jquery-idletimer-plugin/

If you yourself must encode this yourself, you will need to capture the mouse and keyboard events and restart the timer after any of these events. If the timer ever reaches a threshold or counts down to 0 from the threshold, you can reset the page URL.

+5
source

There is also a more modern version of the plugin.

He will be able to trigger an unoccupied event for the entire document or individual elements. For example, a mouse over an element in x seconds, and it fires an event. Another event is fired when the user becomes active again.

This unoccupied event will allow you to redirect the user after a specified period of inactivity.

Supported Activity: mousemove keydown wheel DOMMouseScroll mousewheel mousedown touchstart touchmove MSPointerDown MSPointerMove

https://github.com/thorst/jquery-idletimer

+4
source

All Articles