views:

136

answers:

4

hello,

I am new to asp.net

Can you please guide me what is session and session variables ? Please I don't need a comparision of asp session and asp.net session because I don't know anything about asp.

I have saw 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 ?

Please guide me.

thanks

+1  A: 

Read this article, Web Server Session Management on Wikipedia:

http://en.wikipedia.org/wiki/Session_management#Web_server_session_management

Hope that helps..

Ian

Ian P
+3  A: 

Go through this msdn article about session and session variables

Pandiya Chendur
+2  A: 

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
+2  A: 

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.

isthatacode