views:

34

answers:

1

I would like to pop up a box that warns the user of session timing out in 5 minutes. There are lots of examples of this on the net and I can figure something out. My question however is how to get the time remaining.

All examples I read about set a client side timer to countdown from last postback. I would like to do something different. I would like to make an AJAX call to the server and get the time remaining from the server. Is this possible?

Since an AJAX call will not reset the session timeout timer can I read the number and send it back to the client?

A: 

Surely it must depend on the server you are using. Does it offer an API that lets you obtain the information? If so then exposing a service to allow access to the time is no harder than creating any other service.

However, consider whether this is really worth doing. You will need to send a request to the server periodically to obtain the time remaining. So you are putting load on the infrastructure to obtain information that's pretty trivial to calculate in the client. I can see an argument for asking the server "what's the inactivity timeout setting?" but having got the answer I don't see much objection to doing the actual countdown in the client.

djna
I'm using IIS7.5 and I'm not sure if the information is available. I'm also considering if it is worth doing it. I think a timer on the client that reroutes to a log out screen is better.
Tigran
BTW I agree with you and I used a client side timer.
Tigran