Http​Cookie​Manager Http​Cookie​Manager Http​Cookie​Manager Class

Definition

Add or delete an HttpCookie or view the cookies associated with an app.

public sealed class HttpCookieManager : IHttpCookieManagerpublic sealed class HttpCookieManager : IHttpCookieManagerPublic NotInheritable Class HttpCookieManager Implements IHttpCookieManager
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

The HttpCookieManager object is used to add or delete an HttpCookie or view the cookies associated with an app.

The CookieManager property on HttpBaseProtocolFilter returns an HttpCookieManager object. To construct an HttpCookieManager, a HttpBaseProtocolFilter object is first created and then the CookieManager property on HttpBaseProtocolFilter returns the HttpCookieManager object.

Methods

DeleteCookie(HttpCookie) DeleteCookie(HttpCookie) DeleteCookie(HttpCookie)

Delete an HttpCookie from the cookies associated with an app.

public void DeleteCookie(HttpCookie cookie)public void DeleteCookie(HttpCookie cookie)Public Function DeleteCookie(cookie As HttpCookie) As void
Parameters
cookie
HttpCookie HttpCookie HttpCookie

The HttpCookie to delete.

Attributes

GetCookies(Uri) GetCookies(Uri) GetCookies(Uri)

Gets an HttpCookieCollection that contains the HttpCookie instances that are associated with a specific URI.

public HttpCookieCollection GetCookies(Uri uri)public HttpCookieCollection GetCookies(Uri uri)Public Function GetCookies(uri As Uri) As HttpCookieCollection
Parameters
uri
Uri Uri Uri

The URI of the HttpCookie instances desired.

Returns

The HttpCookieCollection that contains the HttpCookie instances that are associated with a specific URI.

Attributes

Remarks

The GetCookies method creates a new instance of a HttpCookieCollection. Then the HttpCookie instances in the internal collection that are associated with the specified URI are read out and added to the new HttpCookieCollection.

SetCookie(HttpCookie) SetCookie(HttpCookie) SetCookie(HttpCookie)

Add or change an HttpCookie in the cookies associated with an app that is sent on future requests.

public PlatForm::Boolean SetCookie(HttpCookie cookie)public bool SetCookie(HttpCookie cookie)Public Function SetCookie(cookie As HttpCookie) As bool
Parameters
cookie
HttpCookie HttpCookie HttpCookie

The HttpCookie to change or add.

Returns
bool bool bool

true if the HttpCookie replaced an existing cookie; otherwise false.

Attributes

Remarks

If the HttpCookie already exists, then the values and parameters associated the HttpCookie are updated.

If the HttpCookie does not exist, then the HttpCookie is added.

The added or changed HttpCookie will be sent on subsequent HTTP requests.

Setting an HttpCookie doesn't update the HttpCookieCollection previously returned by the GetCookies method.

SetCookie(HttpCookie, Boolean) SetCookie(HttpCookie, Boolean) SetCookie(HttpCookie, Boolean)

Add or change an HttpCookie in the cookies associated with an app.

public PlatForm::Boolean SetCookie(HttpCookie cookie, Boolean thirdParty)public bool SetCookie(HttpCookie cookie, Boolean thirdParty)Public Function SetCookie(cookie As HttpCookie, thirdParty As Boolean) As bool
Parameters
cookie
HttpCookie HttpCookie HttpCookie

The HttpCookie to change or add.

thirdParty
System.Boolean System.Boolean System.Boolean

A value that indicates whether the HttpCookie is a third party HTTP cookie.

Returns
bool bool bool

true if the HttpCookie replaced an existing cookie; otherwise false.

Attributes

Remarks

If the HttpCookie already exists, then the values and parameters associated the HttpCookie are updated.

If the HttpCookie does not exist, then the HttpCookie is added based on policy. For example, the policy might be to reject third-party cookies.

The added or changed HttpCookie will be sent on subsequent HTTP requests.

Setting an HttpCookie doesn't update the HttpCookieCollection previously returned by the GetCookies method.