29-05-2012, 01:06 PM
Session And Page
Session And Page.ppt (Size: 631.5 KB / Downloads: 35)
What is a session ?
A session represents the relationship between a client(browser) and the web server, during the period the user is actively accessing the website.
The relation between a client(browser) and web server is 'Stateless'. This means, once a browser requests a page and server returns it, there is no direct connection between browser and server (until the next page is requested).
However, even though there is no connection is retained between the browser and web server after a request is served, the webserver will still remember the browser's Identity for 'some more' time.
If the browser requests another page within this short timeframe, the server knows that this is a repeated request from a browser it knows. This mechanism is called "Session".
When is a session established ?
A new session is established when a page is requested first time from a website. When you typed the URL http://www.abc.com, a new session is established for you in our web server. The same session is re used every time you hit another page.If you open another browser and type the URL again, it is another session. In that case, two sessions will exists for you at the same time independently.
When and how the session expires
A session expires in the web server, if the browser does not request a page from the server for a 'specific' period of time. This period is configurable and each web server can have it's own session timeout.
The default session time out in ASP.NET is 20 minutes. This means, if you take more than 20 minutes to read a page and click another link, then your session is already expired.
But you may never notice that your session is expired. If you hit a page after the session is expired, the web server will treat this as a brand new request and establish a new session for you. There may not be any visible change for you, in most cases.
But if you are logged in into a web site, most of the sites store your user information in session. If you sit idle for long time, your session may expire and the server will lose all your information from the session. When you hit the site again, it will establish a new session. This is why you are automatically logged out from many sites, if you sit idle for some time.
ASP.NET Session Object
ASP.NET provides a class called HttpSessionState, which is part of the namespace System.Web.SessionState.
Just like Request and Response objects, an HttpSessionState object is also created automatically for you in ASP.NET pages. This object is called "Session".
What is in a session ?
A session has several information including a session ID. Some information is created and used by the server itself. But the most important use of session is, it allows to store custom information.