JavaScript Timer function for session time out.

<script language=“javascript” type=“text/javascript”>
document.onkeypress= reset­Timer
document.onmousemove= reset­Timer
document.onmousedown= reset­Timer
document.Onfocus= reset­Timer

var timerId;

timerId = window.setTimeout(“timeOut()”,7200000);

func­tion reset­Timer() {
window.clearTimeout(timerId);
timerId = window.setTimeout(“timeOut()”,7200000);
}

func­tion time­Out(){
// do some­thing here

alert(“Your ses­sion is times out. You will not be able to con­tin­ue. Please login again ”);
var x=1;
if(x==1){
//do some­thing here
}
}
</script>


Comments

Leave a Reply

%d