Javascript w/My AJAX Callback - Why Doesn't This Work Correctly?

by Joey on 10/31/2007 11:44:00 PM Hey guys, here's what I have...

To help manage browser windows with session state on the server, I
have some javascript code in one of my master pages that gets planted
into most (content) pages on my site...

<script type='text/javascript'>
   var sessionTimer;
   function StartSessionTimer()
   {
      sessionTimer =
window.setTimeout('RedirectToSessionTimedOutPage()', 600000);
   }
   function RestartSessionTimer()
   {
      clearTimeout(sessionTimer);
      StartSessionTimer();
   }
   function RedirectToSessionTimedOutPage()
   {
      window.location = '/SessionTimedOut.aspx';
   }
</script>

For most pages I perform AJAX xml-http callbacks to the server with
UpdatePanels. Then I fire off the 'RestartSessionTimer' client-side
javascript function when the asynchronous call returns from the
server.

The idea is, I set up the code above to handle redirecting browsers to
the
'SessionTimedOut.aspx' page when the value of 600000 milliseconds
(ten minutes) elapses.

But when I do an AJAX callback, I must *reset* the value,
so that the redirect occurs ten minutes from *then*. I have
successfully set up the code to call the client-side
'RestartSessionTimer'
function when the callback finishes, but the value of 600000
apparently is never reset. It always retains (what is remaining) of
the original value.


An example: I load the page and then after about nine minutes (one
minute prior to the 'setTimeout' expiration,) I do actions that make
that
make the callback and that call the 'RestartSessionTimer' function in
the browser. However the page still redirects only a minute later ...
instead of in
*another* ten minutes as intended.


What am I doing wrong here?