Ending a Session in a Web Application

  • Thread starter Thread starter accyboy1981
  • Start date Start date
A

accyboy1981

Hi,

I'm relatively new to C# and am having some problems with sessions. I
have a web application where the user logs in to add comments to a
database. Once the user is logged in this opens the sessions. What I
want to do is to end the session when the user either closes the web
page or navigates to another page. I have tried to do this with the
onunload function but without success. Any help would be appreciated.

Thanks

Simon
 
Simon,
The only way I know to imperatively close a Session is to use the
Session.Abandon method. Otherwise, the Session_End handler in Global will
fire on its own at the server after the sliding timeout period has expired
with no intervening requests, regardless of whether the user is still there
or has gone to lunch.

As far as gaining some level of control where the user leaves the page, try
having a look at the onbeforeunload event.

Peter
 
Back
Top