Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle session end in global.asax?

I'm working in chat application, I used HashTable for containing User and Operator as a Key & Object of ChatRoom Class as a value of HashTable. Main problem is that When user or Operator close browser or disconnected without logout then It is automatically logout on the end of the session.

Please help me related to that and how to use Global.asax in this matter.

like image 326
ashish bhatt Avatar asked Mar 07 '09 11:03

ashish bhatt


People also ask

What occurs when a session ends?

When does a Session End? A session ends if a user has not requested or refreshed a page in the application for a specified period. By default, this is 20 minutes. If you want to set a timeout interval that is shorter or longer than the default, use the Timeout property.

How do I delete a global ASAX session?

Clear() will not cause the Session_End eventhandler in your Global. asax file to execute. But on the other hand Session. Abandon() will remove the session altogether and will execute Session_End eventhandler.


1 Answers

You can use global.asax's session end event to remove the unexpectedly disconnected user :

void Session_End(Object sender, EventArgs E) {
    // Clean up session resources
}

but beware, session doesn't end when the user closes his browser or his connection lost. It ends when the session timeout reached.

like image 169
Canavar Avatar answered Sep 30 '22 20:09

Canavar