JavaScript Response.Redirect after Session Time out

29 Oct

Today looking a way to create a Session Time out Response.Redirect I find this site that have a nice example of creating the functionallity.

Reference:http://www.firozansari.com
Post:http://www.firozansari.com/2009/05/15/implementing-auto-logout-functionality

Code:

Default Page

var timer1, timer2;
document.onkeypress=resetTimer;
document.onmousemove=resetTimer;
function resetTimer()
{
document.getElementById(‘timeoutPopup’).style.display=’none’;
clearTimeout(timer1);
clearTimeout(timer2);

// waiting time in minutes
var wait=10;

// alert user one minute before
timer1=setTimeout(“alertUser()”, (60000*wait)-1);

// logout user
timer2=setTimeout(“logout()”, 60000*wait);
}

function alertUser()
{
document.getElementById(‘timeoutPopup’).style.display=’block’;
}

function logout()
{
window.location.href=’Login.aspx’;
}

#timeoutPopup {
display:none;
position:absolute;
top:0; right:0; bottom:0; left:0;
width:30%;
height:30%;
margin:auto;
padding:4px;
border:solid 1px #999999;
background-color:#dddddd;
text-align:center;
}

Your session is about to expire if there is no additional activity.

Thanks the creator of the forum for the help.

–evick

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: