During asp.net development, Session and Cookie are often used at the same time to store some information. Session data will be found on the home of the script, and there are few Cookie-related information, so I would like to add it. The following is the Cookie writing Syntax:
Copy codeThe Code is as follows:
Response. Cookies ["Cookie name"]. Value = "";
Read Cookie Syntax:
Copy codeThe Code is as follows:
If (Request. Cookies ["Cookie name"]! = Null)
{
String cookieValue = Request. Cookies ["Cookie name"]. Value. ToString ();
}
If you are writing in a category, you need to write the complete name,
Cookie writing Syntax:
Copy codeThe Code is as follows:
System. Web. HttpContext. Current. Response. Cookies ["Cookie name"]. Value = "";
Read Cookie Syntax:
Copy codeThe Code is as follows:
If (System. Web. HttpContext. Current. Request. Cookies ["Cookie name"]! = Null)
{
String cookieValue = HttpContext. Current. Request. Cookies ["Cookie name"]. Value. ToString ();
}