Home > ASP.NET > Session In ASP.NET

Session In ASP.NET

In web when ever webpages request to server entire page will get refreshed, and also since HTTP is stateless protocol we cant maintain store information and all the data will be lost. So how to maintain the information in the stateless environment that where state management come in to picture.

Using Session we can hold the information of the user. Session will be create for each user who accessing the web application. Session object are access with HttpContext.Session property.

Each session have separate sessionID. Client and server communication is happening through sessionID. The data is stored in Session Providers along with the sessionID. If no SessionID value is supplied, ASP.NET starts a new session and the SessionID value for that session is sent to the browser with the response.

By default, SessionID values are stored in a cookie at client side. However, you can also configure the application to store SessionID values in the URL for a “cookie-less” session.

Session will be in active as long as request and response are take place with the same sessionID. If the time between requests for a particular session exceeds the specified time-out value in minutes,the session is considered expired.

Session Variables

Session["FirstName"] = "Kethareeswaran";
Session["LastName"] = "N";

// When retrieving an object from session state, cast it to 
// the appropriate type.
ArrayList stockPicks = (ArrayList)Session["StockPicks"];

// Write the modified stock picks list back to session state.
Session["StockPicks"] = stockPicks;
Categories: ASP.NET Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: