Session variables in asp.net
I have a asp.net webapplicatoin using session variables. I clear the sess开发者_如何学Goion values when session_end is fired but the when the application is opened in a new window after closing the previous window, the session values retain.
is there a way that we can get rid of session values.
Thanks in advance ... Phani
A session does not end when simply closing a window. The session ends when it expires. ASP.NET has no way of knowing if a user closes the window. See MSDN on SessionStateModule.End Event
See this answer for a more thorough explanation.
Of the top of my head, what you could do is detect when the user closes the window e.g. using the unload() event in jQuery, and send a request to a webservice that then ends the session.
New windows/tabs don't create new sessions, new browser instances do.
Also, when the session ends, the session variables are gone. You just can't control when the GC deletes them from memory, however they are no longer accessible.
精彩评论