Session is a feature in ASP.NET that allows storing and retrieving user-specific data across multiple requests. It uses a server-side session object to store data that can be accessed across different pages in the application.
Example 1:
Creating a session variable in C#
Session["username"] = "john123";
In this example, a session variable named "username" is created and assigned the value "john123".
Package/Library: System.Web.SessionState
Example 2:
Retrieving a session variable in C#
string username = (string)Session["username"];
In this example, the value of the session variable "username" is retrieved and assigned to a string variable.
Package/Library: System.Web.SessionState
Example 3:
Removing a session variable in C#
Session.Remove("username");
In this example, the session variable "username" is removed from the session object.
Package/Library: System.Web.SessionState
C# (CSharp) SESSION - 26 examples found. These are the top rated real world C# (CSharp) examples of SESSION extracted from open source projects. You can rate examples to help us improve the quality of examples.