Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

HttpCookie class

Applies to Windows and Windows Phone

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

Syntax

Public NotInheritable Class HttpCookie
    Implements IStringable

Attributes

[DualApiPartition()]
[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06030000)]

Members

The HttpCookie class has these types of members:

Constructors

The HttpCookie class has these constructors.

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

 

Methods

The HttpCookie class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
ToString Returns a string that represents the current HttpCookie object.

 

Properties

The HttpCookie class has these properties.

PropertyAccess typeDescription

Domain

Read-onlyGet the domain for which the HttpCookie is valid.

Expires

Read/writeGet or set the expiration date and time for the HttpCookie.

HttpOnly

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

Name

Read-onlyGet the token that represents the HttpCookie name.

Path

Read-onlyGet the URI path component to which the HttpCookie applies.

Secure

Read/writeGet or set the security level for the HttpCookie.

Value

Read/writeGet or set the value for the HttpCookie.

 

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.

Requirements

Minimum supported client

Windows 8.1 [Windows Store apps, desktop apps]

Minimum supported server

Windows Server 2012 R2 [Windows Store apps, desktop apps]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.Web.Http
Windows::Web::Http [C++]

Metadata

Windows.winmd

See also

HttpCookieCollection
HttpCookieManager
Object
IStringable

 

 

Show:
© 2014 Microsoft