The Session object in ASP.net allows your applications to store information pertaining to a unique user “session“. This session is identified to a user separately for a particular time. The default length of a sesssion is 20 minutes, which time starts after the last page serverd. For example, if you want to keep up with a user login, you could save it with Session[“login“] = username.
Sessions allow your application to store data separately for different users. It is as a Hashtable. The Hashtable Object contains data in key-value pair. The 'pair' will be valid as long as specified, which is usually the session length.
To recover the login as stored above, you could use
username = (string) Session[“login“]
Session Methods
Ø Add - adds a new session key
Ø Abandon - cancels the current session
Ø Clear - clears all values from the session
Ø Remove - removes a session state key
Ø RemoveAll - removes all session state keys
Session Properties
Ø TimeOut Session.Timeout = 30
Ø SessionID Current session ID
Ø IsNewSession Only true for the first page served from web application.
Ø Count Returns the number of keys
Ø IsCookieless If true, the session ID is embedded in the URL, other wise a cookie is used.
Ø Mode Can be one of the following:
-
InProc : Session state is in process with an ASP.NET worker process. (default.)
-
Off : Session state is disabled.
-
StateServer: Session state is using an out-of-process Windows NT Server to store state information.
-
SQLServer: Session state is using an out-of-process SQL Server to store state information.
I hope that this will be useful for you with your ASP.NET applications.
?>