Cookie in ASP. NET: Method for creating a Cookie (1)
Cookie in ASP. NET: Method for creating a Cookie (2)
Cookie in ASP. NET: Access Cookie method (1)
Cookie Access Method (2)
You can clear the Cookie by setting the expiration time.
Protected void Page_Load (object sender, EventArgs e) {if (Request. cookies ["nCount"] = null) {// initialize HttpCookie myVale = new HttpCookie ("nCount", "1"); myVale. expires = DateTime. now. addMonths (1); // The cookie folder Response can only be written later than the current time. write ("1"); Response. cookies. add (myVale); // write} else {HttpCookie cookie = Request. cookies ["nCount"]; // extracts cookie information int n = int. parse (cookie. value) + 1; // Save the updated Value HttpCookie myVale = new HttpCookie ("nCount", n. toString (); myVale. expires = DateTime. now. addMonths (1); // if this line of code is not available, the cookies folder cannot be written. // the output value is Response. write (cookie. value); Response. cookies. add (myVale); // re-overwrite (cannot be modified or deleted. to delete it, you can set an expiration date, which will be automatically deleted by the browser )}}