setting timeout for session

  • Thread starter Thread starter Scott Walters
  • Start date Start date
S

Scott Walters

Hi,

I have an asp.net webapp that uses some javascript in a hidden frame on
the browser to poll the server every 30 seconds, using an http post.

I also want my sessions to timeout in the normal fashion. The way I'm
trying to get around this is by manually setting the timeout property
for the session.

I cache the starting session timeout value and inspect each url I get.
When I get the polling url, I take 30 seconds off the timeout value and
call set_timeout with the new, reduced value. Every time I get a url
different from the polling url, I call set_timeout with the original,
cached value.

Everything seems to be working right in the code, but for some reason
the sessions always end very shortly after the first poll, even if I
continually post with the non-polling url and set the session timeout
value very high in the web.config file.

Can anyone tell me what's going on here?

Thanks,
Scott Walters
 
Instead of continuously reducing the session.timeout property, how about
doing almost the same as you are doing now, but instead of setting the
timeout to a lower and lower value, just keep track of that value in a
variable. When the variable reaches zero, redirect the user to an .aspx page
that contains: Session.Abandon() and displays something like "Your session
has ended.".
 
Back
Top