Recently, I wrote a program and found that there is also a Cookie class under System. Net. By the way, I sorted out the differences between the two cookies:
1. System. Net. Cookie
Indicates the Cookie used by the client. The client application can retrieve the Cookie received over Http.
Follow Cookie specifications: original Netscape specifications, RFC 2109, and RFC 2965. (Important differences)
2. System. Web. Cookie
Indicates the Cookie used by the server. The attribute does not include System. Net. Many cookies.
Compliance with Cookie specifications: Draft Netscape cookie scheme adopted.
The differences between them are as follows:
The System. Web namespace is used for server segments, and System. Net is used for client programs.
In fact, there are more than the following differences:
Next we will compare the attributes of these two Cookie classes as follows. These attributes are all copied from the MSDN Chinese Version instructions:
System. Web. HttpCookie class |
System. Net. Cookie class |
Description of the constructor in MSDN: Overloaded. Initializes a new instance of the HttpCookie class. |
Description of the constructor in MSDN: Overloaded. Initialize a new instance of the Cookie class according to Netscape specifications. Generally, applications do not need to construct Cookie classes because they are automatically created based on the Set-Cookie header received through the HTTP response. |
|
Comment Obtains or sets the comments that the server can add to the Cookie. |
|
CommentUri Obtain or set the URI comments provided by the server through cookies. |
|
Discard Gets or sets the discard flag set by the server. |
Domain Obtain or set the domain associated with the Cookie. |
Domain Obtain or set the valid URI of a Cookie. |
|
Expired Obtains or sets the current status of the Cookie. |
Expires Obtain or set the Cookie expiration date and time. |
Expires Obtain or set the Cookie expiration date and time as DateTime. |
|
HttpOnly Determine whether the page script or other activity content can access this Cookie. |
Name Obtain or set the Cookie name. |
Name Obtain or set the Cookie name. |
Path Obtain or set the virtual path to be transmitted with the current Cookie. |
Path Obtain or set the URI that this Cookie applies. |
|
Port Obtain or set the list of TCP ports that this Cookie applies. |
Secure Gets or sets a value that indicates whether to use Secure Sockets Layer (SSL) (that is, to transmit cookies only through HTTPS. |
Secure Obtains or sets the Cookie security level. |
|
TimeStamp Obtain the time when this Cookie is issued as DateTime. |
Value Obtain or set a single Cookie value. |
Value Obtain or set the Cookie Value. |
Values Obtains the set of key-value pairs contained in a Cookie object. |
|
|
Version Obtain or set the HTTP status maintenance version that meets the Cookie. |