HttpCookieManager HttpCookieManager HttpCookieManager HttpCookieManager HttpCookieManager Class

Definition

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

public : sealed class HttpCookieManager : IHttpCookieManager
struct winrt::Windows::Web::Http::HttpCookieManager : IHttpCookieManager
public sealed class HttpCookieManager : IHttpCookieManager
Public NotInheritable Class HttpCookieManager Implements IHttpCookieManager
// This class does not provide a public constructor.
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) DeleteCookie(HttpCookie)

Delete an HttpCookie from the cookies associated with an app.

public : void DeleteCookie(HttpCookie cookie)
void DeleteCookie(HttpCookie cookie) const;
public void DeleteCookie(HttpCookie cookie)
Public Function DeleteCookie(cookie As HttpCookie) As void
httpCookieManager.deleteCookie(cookie);
Parameters
cookie
HttpCookie HttpCookie HttpCookie

The HttpCookie to delete.

GetCookies(Uri) 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)
HttpCookieCollection GetCookies(Uri uri) const;
public HttpCookieCollection GetCookies(Uri uri)
Public Function GetCookies(uri As Uri) As HttpCookieCollection
var httpCookieCollection = httpCookieManager.getCookies(uri);
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.

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) 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)
bool SetCookie(HttpCookie cookie) const;
public bool SetCookie(HttpCookie cookie)
Public Function SetCookie(cookie As HttpCookie) As bool
var bool = httpCookieManager.setCookie(cookie);
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.

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) SetCookie(HttpCookie, Boolean)

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

public : Platform::Boolean SetCookie(HttpCookie cookie, bool thirdParty)
bool SetCookie(HttpCookie cookie, bool thirdParty) const;
public bool SetCookie(HttpCookie cookie, Boolean thirdParty)
Public Function SetCookie(cookie As HttpCookie, thirdParty As Boolean) As bool
var bool = httpCookieManager.setCookie(cookie, thirdParty);
Parameters
cookie
HttpCookie HttpCookie HttpCookie

The HttpCookie to change or add.

thirdParty
Boolean Boolean 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.

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