재우니의 블로그



https://www.c-sharpcorner.com/forums/user-specific-session-timeout-in-asp-net


javascript 로 page 별 timeout 설정하여 로그아웃 강제시키기

<script type="text/javascript">
var logoutUser = false;
var timeoutHnd = null;
var logouTimeInterval = 15 * 60 * 1000; // 15 mins here u can increase session time
function onuser_activite() {
if (logoutUser) {
;
}
else {
ResetLogOutTimer();
}
}
function OnTimeoutReached() {
logoutUser = true;
alert("You have been automatically Log Off from the system !");
window.location.href = "Logout.aspx";
}
function ResetLogOutTimer() {
clearTimeout(timeoutHnd);
// set new timer
timeoutHnd = setTimeout('OnTimeoutReached();', logouTimeInterval);
}
document.body.onclick = onuser_activite;
timeoutHnd = setTimeout('OnTimeoutReached();', logouTimeInterval);
</script>