19 January 2014

Session Add, Remove, Clear, RemoveAll and Abandon in ASP.NET

Session Add, Remove,  Clear, RemoveAll  and Abandon in ASP.NET

1. Session Add

To add in the Session
For ex

UserID is Session ID
1 is Session value

2. Session Remove

It removes the specific session’s specific key value i.e) It removes the SessionID UserID

3. Session Clear

It clears all session value i.e) It clears all the key value pairs stored in the session state collection.

4. Session RemoveAll

This Method calls above clear method in its implementation,
public sealed class HttpSessionState : ICollection, IEnumerable
   public void RemoveAll()

5. Session Abandon

Session.Abandon() destroy everything in the session. While logout you have to clear everything in session.

No comments:

Post a Comment

Comments Welcome