Session.Clear ();
Does this empty all session on asp.net? Can I delete a specific session, such as Session["USER_ID"].Remove()
? Or session["USER_ID"].Clear ();
Session.Clear ();
Does this empty all session on asp.net? Can I delete a specific session, such as Session["USER_ID"].Remove()
? Or session["USER_ID"].Clear ();
2
Answers
Session.Clear()
can be used if you want that the user remaining in the same session (prevent him from doing relogin) and just reset all of his session specific data. The reason for that is becauseSession.Clear()
Removes all the keys and values from the session-state collection. It actually removes all values from the Object. The session with the same key is still alive.By the way, the
Session.Abandon()
removes all the objects stored in a Session.So, if you use Session.Abandon(), you lose that specific session and the user will get a new session key. You could use it for example when the user logs out.
Check out this article for more info – http://csharpexample.com/CsharpExampleSeeDetail.aspx?Did=78&CatID=29
Session.Clear ();
Removes all keys and values from the session-state collection.Session.Remove();
remove values in session statesee this link
How to remove specific session in asp.net?
also this link can help you
What is the difference between Session.Abandon() and Session.Clear()