View Full Version : Session timer & idle timer

12-03-2012, 04:21 PM

Like i said in this thread: http://www.codingforums.com/showthread.php?t=283412

I'm building a CMS with session timer and idle timer and i was wondering if it's anything to do with jQuery or JS?!?!?!?

Much help would be appreciated.

Philip M
12-03-2012, 05:31 PM
This script will redirect if no mouse movement has been detected after x seconds, but bear in mind it only works if Javascript is enabled in the browser.


<script type = "text/javascript">

var timeInSecs;
var ticker;
var tim;

function check() {
startTimer(6); // start or re-start the timer - 6 seconds - change to 60 for one minute, 3600 for 60 minutes

function startTimer(secs){
timeInSecs = parseInt(secs);
ticker = setInterval("tick()",1000);

function tick() {
var secs = timeInSecs;
document.getElementById("countdown").innerHTML = secs; // REMOVE AFTER TESTING
if (secs>0) {
else {
clearInterval(ticker); // stop counting at zero
document.getElementById("message").innerHTML="Unless you move your mouse within 60 seconds you will be disconnected";
tim = window.setTimeout("disconnect()", 6000); // 6 seconds - change to 60000 for 60 seconds

function disconnect() {
window.location = "http://www.google.com";


<body onmousemove = "check()">

<div id = "countdown"></div><br>
Remove countdown div after testing unless you wish to show this.
<div id = "message" style = "font-size:18pt;font-weight:bold;text-align:center;color:red;";></div>


"If you think education is expensive, try ignorance." - Derek Bok (1930-), Harvard University President