This article will show you how you can kill or remove a session in your mvc application. So there are three ways by which we can remove the session in mvc Session.Abandon, Session.Remove and Session.Clear.
So here i will show code for using this.
Session.Abandon:
The Abandon method destroys all the objects stored in a Session object and releases the memort location.If you do not call the Session Abandon method explicitlyom that case server will destroys the objects when the session times out.
Session.Remove:
It is use for removing the session of a specific key. In this we need to provide the key name which we want to kill.
Session.Clear:
So here i will show code for using this.
Session.Abandon:
The Abandon method destroys all the objects stored in a Session object and releases the memort location.If you do not call the Session Abandon method explicitlyom that case server will destroys the objects when the session times out.
Session.Abandon();
|
It is use for removing the session of a specific key. In this we need to provide the key name which we want to kill.
Session.Remove("KeyName");
|
Session.Clear removes all keys and values from the session-state collection.
Session.Clear();
|
0 comments:
Please let me know your view