...

session.Timeout query

pthompson2002
08-09-2002, 01:42 PM
I would like to know if the following is possible using session.timeout or session variables.

I have a timeout counter that counts down to 0.00 then times the user out and forces them to log back in again. I would like the counter to 'reset' if the user presses a link or clicks a button. In short, i only want it to timeout if the user is inactive.
I have been told it is possilbe to do this via a session variable.

The page is split into three frames a header, menu and main body.

All the functionality for starting the timer and displaying it are in the header as that is where the counter is displayed on the browser. Here is the code if it is any use.

<script language="javascript">
var running = false
var endTime = null
var timerID = null
browser = navigator.appName

function startTimer() {
running = true
now = new Date()
now = now.getTime()
// If middle integer set to 60, then just change far right integer to number of mins required
endTime = now + (1000 * 10 * 1)
showCountDown()

return true;
}

function showCountDown() {
var now = new Date()
now = now.getTime()
if (endTime - now <= 0) {
stopTimer()
parent.maintask.location.href ='timeOut.htm';
} else {
var delta = new Date(endTime - now)
var theMin = delta.getMinutes()
var theSec = delta.getSeconds()
var theTime = theMin
theTime += ((theSec < 10) ? ":0" : ":") + theSec
if (document.layers)
{
document.ns4timer.document.ns4timer2.document.write(theTime);
document.ns4timer.document.ns4timer2.document.close();
}
if (document.all)
{
timer.innerHTML = '<font size=2>' + theTime + '</font>';
}
if (document.getElementById && document.createRange)
{
rng = document.createRange();
el = document.getElementById("N6timer");
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragment(theTime);
while (el.hasChildNodes())
el.removeChild(el.lastChild);
el.appendChild(htmlFrag);
}
if (running) {
timerID = setTimeout("showCountDown()",1000)
}
}
}


function stopTimer() {
clearTimeout(timerID)
running = false
if (document.layers)
{
document.ns4timer.document.ns4timer2.document.write("0:00");
document.ns4timer.document.ns4timer2.document.close();
}
if (document.all)
{
timer.innerHTML = '<font size=2>0:00</font>';
}
if (document.getElementById && document.createRange)
{
rng = document.createRange();
el = document.getElementById("N6timer");
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragment("0:00");
while (el.hasChildNodes())
el.removeChild(el.lastChild);
el.appendChild(htmlFrag);
}
}
</script>

I know its JavaScript and not ASP but I am truly stumped and trying any avenue.

thanks

Pete

allida77
08-09-2002, 02:21 PM
The session has a timeout property which will terminate a users session if they are idle for the allotted time.

<%Session.Timeout = 20%>

You can put an

Sub Session_OnEnd()
Response.Redirect "login.asp"
End Sub

in your global.asa file.

I have not tested this, but this is what I would try.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum