5

Can you please guide me what is session and session variables? I don't need a comparison of ASP session and ASP.NET session because I don't know anything about ASP.

I have seen many articles on types of session as well. But still I can't understand correctly what is session and what are session variables in ASP.NET?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
haansi
  • 5,470
  • 21
  • 63
  • 91

3 Answers3

18

Session - Is to keep track of each user's request. So each time the web page is posted back asp.net runtime knows from which user the request is coming from. Now since HTTP is a stateless protocol, meaning each request from the same user is like a new request to it. So, to maintain a session Asp.Net has Session variables.

Session Variables- The session variables are variables maintained on server side by asp.net runtime. Each user is identified by a a unique number called SessioID. This session is stored in a cookie (if browser supports cookie) on client side after the first user request. when the client posts back a page , this cookie is available in the request header. So now server knows that this user request is coming from which user. Besides this you can also store user specific information in session variables, which will be availale on server side.

Rasshme Chawla
  • 1,581
  • 2
  • 13
  • 19
4

From Here

ASP.NET session state enables you to store and retrieve values for a user as the user navigates ASP.NET pages in a Web application.

HTTP is a stateless protocol. This means that a Web server treats each HTTP request for a page as an independent request. The server retains no knowledge of variable values that were used during previous requests. ASP.NET session state identifies requests from the same browser during a limited time window as a session, and provides a way to persist variable values for the duration of that session.

By default, ASP.NET session state is enabled for all ASP.NET applications.

Session Variables:

Session variables are stored in a SessionStateItemCollection object that is exposed through the HttpContext.Session property. In an ASP.NET page, the current session variables are exposed through the Session property of the Page object.

MAS1
  • 1,691
  • 6
  • 19
  • 22
-1

Sessions store the user information on the server side like uid and pass. Session is a server side state management technique. When you first login, you are often assigned a unique session id that is stored on a cookie (if cookies are supported) which is in turn passed back to the server with each request so it can retrieve your session.

corsiKa
  • 81,495
  • 25
  • 153
  • 204