开发者

Session variables in asp.net

开发者 https://www.devze.com 2023-04-01 08:22 出处:网络
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 pr

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号