Write:
Copy Code code 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_");
May be Chinese characters, 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 Code code as follows:
Httpcontext.current.request.cookies["GUID"]. Value
asp.net empty cookies empty individual
Copy Code code as follows:
response.cookies["Admin"]. Expires = DateTime.Now.AddDays (-1);
asp.net empty cookies empty all
Request.Cookies.Clear () This method does not delete cookies
deleting cookies (that is, physically removing cookies from the user's hard disk) is a form of modifying cookies.
Because the Cookie is on the user's computer, it cannot be removed directly.
However, you can have your browser remove cookies for you.
The technique is to create a new cookie with the same name as the cookie you want to delete.
and set the expiration date of the Cookie to a date earlier than the current date.
When the browser checks the expiration date of the cookie, the browser discards the cookie that is now expired.
The following code example demonstrates a way to delete all available cookies in an application:
Copy Code code as follows:
HttpCookie Acookie;
String CookieName;
int limit = Request.Cookies.Count;
for (int i = 0; i < limit; i++)
{
CookieName = Request.cookies[i]. Name;
Acookie = new HttpCookie (cookiename);
Acookie.expires = DateTime.Now.AddDays (-1);
RESPONSE.COOKIES.ADD (Acookie);
}