HttpCookieManager HttpCookieManager HttpCookieManager HttpCookieManager 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// You can use this class in JavaScript.
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) 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// You can use this method in JavaScript.
Parameters

GetCookies(Uri) 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// You can use this method in JavaScript.
Parameters
uri
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.

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.

Below are the exceptions that this function throws.

E_INVALIDARG

The uri parameter was a null reference (Nothing in Visual Basic).

SetCookie(HttpCookie) 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// You can use this method in JavaScript.
Parameters
cookie
HttpCookie HttpCookie HttpCookie HttpCookie

The HttpCookie to change or add.

Returns
PlatForm::Boolean bool bool bool

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

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.

See Also

SetCookie(HttpCookie, Boolean) 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, bool thirdParty)public bool SetCookie(HttpCookie cookie, Boolean thirdParty)Public Function SetCookie(cookie As HttpCookie, thirdParty As Boolean) As bool// You can use this method in JavaScript.
Parameters
cookie
HttpCookie HttpCookie HttpCookie HttpCookie

The HttpCookie to change or add.

thirdParty
bool Boolean Boolean Boolean

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

Returns
PlatForm::Boolean bool bool bool

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

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.

See Also