<script type="text/javascript" language="javascript">
sessionTimeout = <%= Session.Timeout %> ;
now = new Date();
newtime = now.setMinutes(now.getMinutes() + parseInt(sessionTimeout));
function Session_Expiry(session1) {
now = new Date();
diff = newtime - now;
days = Math.floor(diff / (1000 * 60 * 60 * 24));
hours = Math.floor(diff / (1000 * 60 * 60));
mins = Math.floor(diff / (1000 * 60));
secs = Math.floor(diff / 1000);
mm = mins - hours * 60;
ss = secs - mins * 60;
if(mm<10 && mm>=0)
{
mme='0'+mm;
}
else
{
mme=mm;
}
if(ss<10 && ss>=0)
{
sse='0'+ss;
}
else
{
sse=ss;
}
sessionresult ='Session will expiry in '+ mme + ':' + sse + ' Secs';
document.getElementById(session1).innerHTML = sessionresult;
if(secs<=0)
{
window.location.href='Login.aspx';
}
setTimeout('Session_Expiry("'+session1+'");','1000');
return true;
}
</script>
in body
<td style="width:240px">
<span id="Session_Expiry" class="Session_Expiry"></span>
<script type="text/javascript">window.onload = Session_Expiry('Session_Expiry');</script>
</td>
sessionTimeout = <%= Session.Timeout %> ;
now = new Date();
newtime = now.setMinutes(now.getMinutes() + parseInt(sessionTimeout));
function Session_Expiry(session1) {
now = new Date();
diff = newtime - now;
days = Math.floor(diff / (1000 * 60 * 60 * 24));
hours = Math.floor(diff / (1000 * 60 * 60));
mins = Math.floor(diff / (1000 * 60));
secs = Math.floor(diff / 1000);
mm = mins - hours * 60;
ss = secs - mins * 60;
if(mm<10 && mm>=0)
{
mme='0'+mm;
}
else
{
mme=mm;
}
if(ss<10 && ss>=0)
{
sse='0'+ss;
}
else
{
sse=ss;
}
sessionresult ='Session will expiry in '+ mme + ':' + sse + ' Secs';
document.getElementById(session1).innerHTML = sessionresult;
if(secs<=0)
{
window.location.href='Login.aspx';
}
setTimeout('Session_Expiry("'+session1+'");','1000');
return true;
}
</script>
in body
<td style="width:240px">
<span id="Session_Expiry" class="Session_Expiry"></span>
<script type="text/javascript">window.onload = Session_Expiry('Session_Expiry');</script>
</td>
No comments:
Post a Comment