Remove HttpContext.Current.Session

佐手、 提交于 2020-01-03 18:57:09

问题


I have an application which stores session variables. When I do the logout I call the RemoveAll() method on available sessions.

The method seems not working. Do you know how it is possible to force removing a Session variable?

Regards.


回答1:


Session.Abandon()

cancels the current session

Session.Clear() 

will just clear the session data and the the session will remain alive

more Details:

Session.Abandon() method destroys all the objects stored in a Session object and releases their resources. If you do not call the Abandon method explicitly, the server destroys these objects when the session times out(I may add:Session_OnEnd event is triggered)

http://msdn.microsoft.com/en-us/library/ms524310.aspx

Session.Clear() just removes all values (content) from the Object. The session with the same key is still alive.



来源:https://stackoverflow.com/questions/6927766/remove-httpcontext-current-session

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!