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

J

Joey

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?
 
G

Guest

if you are using cookie based sessions, then update panels' xmlhttprequest do
not update the browser cookie, so after the cookie timesouts, the update
panel request will not contain the session cookie and your page will not have
session (even though the session is still alive on the server).

most likely the update panel is getting an error back, and not calling you
reset timer event.


-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top