ASP tutorials. NET application cookies sessions server built objects
Many objects are built into the ASP.net tutorial, including application, response, request, cookies, sessions, cache, server, and viewstate. Through these objects, you can provide some essential features of the site, such as the absolute path to the file, the number of people online, the total number of visitors to the site, online store shopping box.
The cookie object uses the key/value pair method to record the data, and the statement mycookie.expires=datetime.now.addhours (1) specifies when the data in the cookie expires, which is 1 hours after the expiration. If you do not specify an expiration time, exiting the Web page immediately expires.
Write
The value of the cookie is as follows:
HttpCookie mycookie=new HttpCookie ("userinfo");
Mycookie.value=2.tostring ();
Mycookie.expires=datetime.now.addhours (1); Response.Cookies.Add (MyCookie);
The value of the cookie is removed by the following methods:
HttpCookie mycookie=request.cookies["UserInfo"];
int num=convert.toint16 (MyCookie.
Value
);