Session Add, Remove, Clear, RemoveAll and Abandon in ASP.NET
1. Session Add
To add in the Session
For ex
Session.Add("UserID",1);
or
Session["UserID"]=1;
UserID is Session ID
1 is Session value
2. Session Remove
Session.Remove(“UserID”);
It removes the specific session’s specific key value i.e) It removes the SessionID UserID
3. Session Clear
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
Session.RemoveAll();
This Method calls above clear method in its implementation,
public sealed class HttpSessionState : ICollection, IEnumerable
{
.....
public void RemoveAll()
{
this.Clear();
}
.....
}
5. Session Abandon
Session.Abandon() destroy everything in the session. While logout you have to clear everything in session.
Dotnet, DotnetCore, Azure, C#,VB.net, Sql Server, WCF, MVC ,Linq, Javascript and Jquery
Showing posts with label Session Add. Show all posts
Showing posts with label Session Add. Show all posts
Subscribe to:
Posts (Atom)
Implementing OAuth validation in a Web API
I mplementing OAuth validation in a Web API Implementing OAuth validation in a Web API using C# typically involves several key steps to sec...
-
ViewBag, ViewData, TempData and View State in MVC ASP.NET MVC offers us three options ViewData, ViewBag and TempData for passing data from...
-
// Export Datatable to Excel in C# Windows application using System; using System.Data; using System.IO; using System.Windows.Forms; ...