The following describes the use of Session objects to pass and share data usage in asp:
1, pass the value:
First, define a text value or a single value to the session, as follows:
session["Name"]=TEXTBOX1.TEXT; assigns the value of text 1 to the session variable name, which can be passed when the other page is investigated, and is still present, and this value is called or judged.
If (session["name"]==null)
{}
Else
{
lable1.text=session["Name"].tostring (); Pass the session variable to Lable1.text
}
2. Delivery Web page:
The following is a button event:
session["Address" = "index.aspx";
Response.Redirect (session["address"). ToString ());
3.session Concrete Method Introduction:
The session object corresponds to the HttpSessionState class in. NET, which means "conversation state", which can hold information related to the current user session.
The session object is used to store the information that is required for a particular user session from the beginning of a user's access to a particular ASPX page, until the user leaves. The variables of the session object are not cleared when the user switches the application's page.
For a Web application, the content of the Application object accessed by all users is exactly the same, while the content of the session object accessed by different user sessions varies. Session can save the variable, which can only be used by one user, that is, each Web browser has its own session object variable, that is, the session object is unique.
(1) Add new item to session state
The syntax format is:
Session ("key name") = value
Or
Session.add ("Key Name", value)
(2) Get the value in session state by name
The syntax format is:
Variable = Session ("Key Name")
Or
Variable = session.item ("Key Name")
(3) Delete an item in the session-state collection
The syntax format is:
Session.remove ("Key Name")
(4) Clear all values in the session state
The syntax format is:
Session.removeall ()
Or
Session.clear ()
(5) Cancel the current session
The syntax format is:
Session.Abandon ()
(6) Sets the time-out period for session state, in minutes.
The syntax format is:
Session.Timeout = value
2 events in the Global.asax file are applied to the session object
Event name Description
Session_Start fires when a session is started
Session_End fires at the end of a session