HttpCookie Class

HttpCookie Class

Provides a type-safe way to create and manipulate individual HTTP cookies.

Remarks

The HttpCookie class gets and sets properties of individual cookies. The HttpCookieCollection class provides methods to store, retrieve, and manage multiple cookies.

ASP.NET includes two intrinsic本质的,固有的 cookie collections. The collection accessed through the Cookies collection of the HttpRequest object contains cookies transmitted传输 by the client to the server in the Cookie header. The collection accessed through the Cookies collection of the HttpResponse object contains new cookies created on the server and transmitted to the client in the Set-Cookie HTTP response header.

 

Properties

Table 2
Domain

Gets or sets the domain to associate the cookie with.

Expires

Gets or sets the expiration date and time for the cookie.

HasKeys

Gets a value indicating whether a cookie has subkeys.

HttpOnly

Gets or sets a value that specifies whether a cookie is accessible by client-side script.

Item[String]

Gets a shortcut to the Values property. This property is provided for compatibility with previous versions of Active Server Pages (ASP).

Name

Gets or sets the name of a cookie.

Path

Gets or sets the virtual path to transmit with the current cookie.

SameSite

Gets or sets the value for the SameSite attribute of the cookie.

Secure

Gets or sets a value indicating whether to transmit the cookie using Secure Sockets Layer (SSL)--that is, over HTTPS only.

Shareable

Determines whether the cookie is allowed to participate in output caching.

Value

Gets or sets an individual cookie value.

Values

Gets a collection of key/value pairs that are contained within a single cookie object.

 

HttpCookie.SameSite Property

Gets or sets the value for the SameSite attribute of the cookie.

One of the enumeration values that represents the enforcement执行,实施;强制 mode of the cookie or (SameSiteMode)(-1) (represented by the string Unspecified in config files). The default value depends on updates. For more information on defaults and recent updates, see Remarks.

Remarks

The default value of this property was modifed by updates described in KB article 4531182 and KB article 4524421.

Without these updates, the default value is SameSiteMode.None, which does not emit发出,放射;发行;发表 the SameSite cookie header. This conforms to https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-4.1.

After these updates have been applied, the default value is (SameSiteMode)(-1), which corresponds to Unspecified. This preserves the earlier behavior. Setting SameSiteMode.None causes "SameSite=None" to be emitted. This new behavior conforms to https://tools.ietf.org/html/draft-west-cookie-incrementalism-00.

 

posted @ 2020-06-22 15:35  ChuckLu  阅读(225)  评论(0)    收藏  举报