Write and read an introduction to two different syntaxes of Cookie on the Asp.net page

  • 2020-05-24 05:27:48
  • OfStack

When doing asp.net development, this site is often used with Session and Cookie in order to store some information. The materials of Session will find a lot of relevant information on this site, while the materials related to Cookie are relatively few, so I would like to add 1. Here's the syntax for Cookie:
 
Response.Cookies[" The name of the cookie "].Value = " The home of the script "; 

Read Cookie grammar:
 
if (Request.Cookies[" The name of the cookie "] != null) 
{ 
string cookieValue = Request.Cookies[" The name of the cookie "].Value.ToString(); 
} 

If you're writing in a category, you need to write the full name,
Write Cookie grammar:
 
System.Web.HttpContext.Current.Response.Cookies[" The name of the cookie "].Value = " The home of the script "; 

Read Cookie grammar:
 
if (System.Web.HttpContext.Current.Request.Cookies[" The name of the cookie "] != null) 
{ 
string cookieValue = HttpContext.Current.Request.Cookies[" The name of the cookie "].Value.ToString(); 
} 

Related articles: