How to explicitly end users Session?

 Copyright © 2007-2012 www.AspDotNetFaq.com

To programmatically end current users session (for any reason) we can use Session.Abandon method.

When this method is called, current session becomes no longer valid (its destroyed) and new session can be started.
This method also causes End event of the Web Application to be fired.
You can specify a handler for the End event by adding a code to the Session_End method in the Global.asax file.

A Web Application Start event will be raised on the next request (this event can be handled by placing your code into Session_Start method in your Global.asax file) and a new Session will be created for the current user that requested the page.

NOTE: Session End event fires only when Session Mode is set to InProc.





 Copyright © 2007-2012 www.AspDotNetFaq.com