SESSION method

xiaoxiao2021-03-06  39

The current understanding of the session is that session is the user variable saved on the server. I can value the session in a page, then access it in another page.

The value of the session is as follows:

INT userid = 1; string username = "test"; string userpwd = "e10adc3949ba59abbe56e057f20f883e"

SESSION ["UserID"] = UserId; session ["username"] = username; session ["userpwd"] = userpwd;

Or use the SESSION ADD method

Session.Add ("UserID", UserID; session.add ("username", username; session.add ("userpwd", userpwd);

This is a bit like creating a hash table :)

Add the above code in the page_load event in WebForm1.cs, then add the following code in a WebForm2.cs Page_Load Event:

Lable1.text = session ["userid"]. TOSTRING (); lable2.text = session ["username"]. Tostring (); lable3.text = session ["Userpwd"]. Tostring ();

Next, open WebForm1.aspx first, then open WebForm2.aspx, you can see the value attached to the session variable in WebForm1.cs before. Related Articles: [转] ASP.NET Session Detailed Code: Pass data from a web form page to another web form page (Visual C #)

转载请注明原文地址:https://www.9cbs.com/read-76486.html

New Post(0)