Write:
CopyCode The Code is as follows: httpcookie cookie = new httpcookie ("id_admin _");
Cookie. value = model. id_admin _. tostring ();
// Cookie. Domain = ".sosuo8.com ";
Httpcontext. Current. response. Cookies. Add (cookie );
Cookie = new httpcookie ("name_admin _");
// It may be a Chinese character and must be encoded
Cookie. value = httputility. urlencode (model. name_admin _);
// Cookie. Domain = ".sosuo8.com ";
Httpcontext. Current. response. Cookies. Add (cookie );
Cookie = new httpcookie ("guid ");
Cookie. value = guid. newguid (). tostring ();
// Cookie. Domain = ".sosuo8.com ";
Httpcontext. Current. response. Cookies. Add (cookie );
Read:Copy codeThe Code is as follows: httpcontext. Current. Request. Cookies ["guid"]. Value
Asp.net clear cookie clear a single Copy codeThe Code is as follows: Response. Cookies ["admin"]. expires = datetime. Now. adddays (-1 );
Asp.net clear cookie clear all
Request. Cookies. Clear () is not used to delete cookies.
deleting a cookie (physically removing a cookie from a user's hard disk) is a form of cookie modification.
the cookie cannot be directly removed because it is on the user's computer.
however, the browser can delete cookies for you.
This technique creates a new cookie with the same name as the cookie to be deleted.
set the cookie expiration date to a date earlier than the current date.
when the browser checks the cookie expiration date, the browser discards the expired cookie.
the following code example demonstrates how to delete all available cookies in the Program of an Application: copy Code the code is as follows: httpcookie acookie;
string cookiename;
int Limit = request. cookies. count;
for (INT I = 0; I {< br> cookiename = request. cookies [I]. name;
acookie = new httpcookie (cookiename);
acookie. expires = datetime. now. adddays (-1);
response. cookies. add (acookie);
}