Auto logout when user not using website
Auto logout when user not using website
Problem:
if user is not using website for some time, user sh'd be logout automatically.
Solution:
add below code in "Java Script"
function idleLogout() {
var t;
window.onload = resetTimer;
window.onmousemove = resetTimer;
window.onmousedown = resetTimer; // catches touchscreen presses
window.onclick = resetTimer; // catches touchpad clicks
window.onscroll = resetTimer; // catches scrolling with arrow keys
window.onkeypress = resetTimer;
function logout() {
window.location.href ='/Account/SignOut'; // URL to logout page.;
}
function resetTimer() {
clearTimeout(t);
var timeOutValue = 240000; //240000 milliseconds = 4 mints = (if sysem remain idle for 5 mints API session is expired.)
timeOutValue = 60 * 60000; // 60 mints = 1 hour
// timeOutValue = 1 * 6000; // few secswond
t = setTimeout(logout, timeOutValue);
}
}
idleLogout();
Share This with your friend by choosing any social account