Data stored in a Session object hold information about one single user, and are available to all pages in one application.Session state is associated with a browser session. A session starts when the client first opens an ASP.NET page on the server, and ends when the client doesn’t access the server for 20 minutes. If you want to set a timeout interval that is shorter or longer than the default, use the Timeout property.Also use Abandon method to end a session immediately
Set data By:
Retrive data using :
Session.Timeout = 5;
Session.Abandon();
Session state can be stored within an HttpSessionState object. The session state object associated with the current HTTP context can be accessed with the Session property of the Page class. In the Session_Start() event handler, session variables can be initialized.All Session events declared in Global.asax file.Set data By:
void Session_Start(Object
sender, EventArgs e)
{
Session["mydata"]
= 0;
}
Retrive data using :
void Button1_Click(object
sender, EventArgs e)
{
int val = (int)Session["mydata"];
val += 4;
Session["mydata"]
= val;
}
No comments:
Post a Comment