Provides a set of properties and methods to manage an HTTP cookie.
The HttpCookie class has these types of members:
The HttpCookie class has these constructors.
|HttpCookie||Initializes a new instance of the HttpCookie class with a specified name, domain, and path.|
The HttpCookie class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
|ToString||Returns a string that represents the current HttpCookie object.|
The HttpCookie class has these properties.
|Read-only||Get the domain for which the HttpCookie is valid.|
|Read/write||Get or set the expiration date and time for the HttpCookie.|
|Read/write||Get or set a value that controls whether a script or other active content can access this HttpCookie.|
|Read-only||Get the token that represents the HttpCookie name.|
|Read-only||Get the URI path component to which the HttpCookie applies.|
|Read/write||Get or set the security level for the HttpCookie.|
|Read/write||Get or set the value for the HttpCookie.|
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.
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]|