Net-informations.com
SiteMap  | About    

ASP.NET Session State

A session is defined as the period of time that a unique user interacts with a Web application. When a new user begins to interact with the application, a new session ID is generated and associated with all subsequent requests from that same client and stored in a cookie on the client machine.

Session state is maintained in an instance of the HttpSessionState class and is accessible through the Session property of both the Page and HttpContext classes. It is not necessary for you to instantiate the Session Object. An instance is automatically provided for you. The Session object allows you to maintain a list of name/value pairs that can be accessed by any Web page in your application.

vb.net
  Dim username As String
  If Session("userName") IsNot Nothing Then
	username = Session("userName")
  Else
	Session("userName") = "John"

End If

C#
  string username;
  if (Session["userName"] != null)
  {
	username = (String)Session["userName"];
  }
  else
  {
	Session["userName"] = "John";

}

For every client Session data store separately, means session data is stored as per client basis. Along with advantages, some times session can causes performance issue for heavy traffic sites because its stored on server memory and clients read data from the server itself.






net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.