مشاركة عبر


HttpCookie Class

Definition

Provides a set of properties and methods to manage an HTTP cookie.

public ref class HttpCookie sealed : IStringable
/// [Windows.Foundation.Metadata.Activatable(Windows.Web.Http.IHttpCookieFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class HttpCookie final : IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Web.Http.IHttpCookieFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class HttpCookie final : IStringable
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Web.Http.IHttpCookieFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class HttpCookie : IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Web.Http.IHttpCookieFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class HttpCookie : IStringable
function HttpCookie(name, domain, path)
Public NotInheritable Class HttpCookie
Implements IStringable
Inheritance
Object Platform::Object IInspectable HttpCookie
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Remarks

Cookies are small chunks of data that are passed between HTTP servers and clients. Their primary use is by the web server developers to save session state. The web server developer uses the state to correlate earlier and later requests. For example, session state can include a unique visitor id which is then used to remember (on the server side) the visitor’s shopping cart.

The HTTP server sends cookies to the client with the Set-Cookie header. The client sends them back with the Cookie header. Cookies that are sent back don’t include cookie attributes. The correct cookie usage is that the server sets a cookie once and doesn’t re-set it on subsequent responses. This works because a cookie, once set, will be sent back until it expires or is deleted (as long as it matches the URI correctly). Cookies are persistent when they have a valid Expires header. Cookies that are not persistent are session cookies, and are not persisted from one session to another.

Although cookies are commonly used by web services developers, they are sometimes used by client-side developers.

Constructors

HttpCookie(String, String, String)

Initializes a new instance of the HttpCookie class with a specified name, domain, and path.

Properties

Domain

Get the domain for which the HttpCookie is valid.

Expires

Get or set the expiration date and time for the HttpCookie.

HttpOnly

Get or set a value that controls whether a script or other active content can access this HttpCookie.

Name

Get the token that represents the HttpCookie name.

Path

Get the URI path component to which the HttpCookie applies.

Secure

Get or set the security level for the HttpCookie.

Value

Get or set the value for the HttpCookie.

Methods

ToString()

Returns a string that represents the current HttpCookie object.

Applies to

See also