• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 436
  • Last Modified:

Expiring of Sessions in ASP.NET

In ASP.NET after having set the Session timeout to 20 minutes, if the users close the browser window without logging out , is there a way to identify such clients from the Server without having to wait for 20 minutes and expiring those sessions?
5 Solutions
The web is stateless. And because of that, the feature you want is not possible. Have fun...
There is no way to do that from a server.
Maybe u can do that in the application's unload function.
The only way to do it is with client side code.  You can use a hidden frame or iframe with a function that sends accross a refresh request on a regular basis; say every minute of 30 seconds.  When the refresh messages quit coming th user has move off with out logging off and you can expire the session.

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

When drawing a page, pass a variable to it: if it is a form, include dynamically a hidden field called, for example, time, containing the hour when the page was dynamically drawn. If the page is not a form, pass a variable to it on the url (something like page.asp?time=1005.

At the beginning of all pages you want to expire, put a routine to verify the time on that variable with the time on server and expire it when desired.
Why dont you reduce the sesson time out to say 5 minutes, if they are using the site then the session will remain valid, if they stop using it they will have to login in again.

Another way would be for you to set up some client side javascript that acts like a hearbeat if the page is still loaded into the browser window, if the hear beat stops for that user, expire their login
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now