var sessPollInterval = 30000; //How frequently to check for session expiration in milliseconds? var sessExpirationMinutes = 25; //How many minutes the session is valid for? var sessIntervalID; var sessLastActivity; function GetExpirationMinutes() { sessExpirationMinutes = 25; } function InitSession() { sessLastActivity = new Date(); sessSetInterval(); $(document.body).bind('mousemove keydown click', sessKeyPressed); } function sessSetInterval() { sessIntervalID = setInterval('sessInterval()', sessPollInterval); } function sessClearInterval() { clearInterval(sessIntervalID); } function sessKeyPressed(ed, e) { sessLastActivity = new Date(); } function sessLogOut() { window.location.href = 'EMSLogin.aspx?Logout=true'; } function sessInterval() { var now = new Date(); var diff = now - sessLastActivity; //Get differneces in milliseconds var diffMins = (diff / 1000 / 60); //Get differences in minutes sessExpirationMinutes = GetExpirationMinutes(); if (diffMins >= sessExpirationMinutes) { sessLogOut(); } }