In ASP.NET, when should I use Session.Clear() rather than Session.Abandon()?

后端 未结 4 610
滥情空心
滥情空心 2020-11-28 19:32

Both Session.Clear() and Session.Abandon() get rid of session variables. As I understand it, Abandon() ends the current session, and causes a new session to be created thus

4条回答
  •  渐次进展
    2020-11-28 19:43

    Session.Abandon destroys the session as stated above so you should use this when logging someone out. I think a good use of Session.Clear would be for a shopping basket on an ecommerce website. That way the basket gets cleared without logging out the user.

提交回复
热议问题