CookieStore Class

The Cookie Store API of a window (https://cookiestore.spec.whatwg.org/#cookiestore): reads and writes the script-visible cookies of BrowsingContextOptions.CookieJar for the creation URL of the document (which history.pushState() does not change), and fires change events when they change.

public sealed class CookieStore : EventTarget

Remarks

The cookies set by this API are Secure. A document without cookie jar has no cookies: the cookies it sets are ignored. The change events are fired for the changes of the jar observable from the document (the cookies of other documents, of the responses, and of document.cookie).

See also

Inheritance
EventTarget CookieStore

Properties

NameDescription
OnChangeThe event handler of the change events (https://cookiestore.spec.whatwg.org/#dom-cookiestore-onchange).

The event handler of the change events (https://cookiestore.spec.whatwg.org/#dom-cookiestore-onchange).

public Action<Event>? OnChange { get; set; }

Methods

NameDescription
Delete(CookieStoreDeleteOptions)Deletes a cookie (https://cookiestore.spec.whatwg.org/#dom-cookiestore-delete-options).
Delete(string)Deletes the cookie with the name and the path / (https://cookiestore.spec.whatwg.org/#dom-cookiestore-delete).
Get(CookieStoreGetOptions?)Returns the first script-visible cookie matching the options (https://cookiestore.spec.whatwg.org/#dom-cookiestore-get-options), or null.
Get(string)Returns the first script-visible cookie with the name (https://cookiestore.spec.whatwg.org/#dom-cookiestore-get), or null.
GetAll(CookieStoreGetOptions?)Returns the script-visible cookies matching the options (https://cookiestore.spec.whatwg.org/#dom-cookiestore-getall-options).
GetAll(string)Returns the script-visible cookies with the name (https://cookiestore.spec.whatwg.org/#dom-cookiestore-getall).
Set(CookieInit)Sets a cookie (https://cookiestore.spec.whatwg.org/#dom-cookiestore-set-options).
Set(string, string)Sets a cookie for the path /, Secure and SameSite=Strict (https://cookiestore.spec.whatwg.org/#dom-cookiestore-set).

Delete overloads

Delete(CookieStoreDeleteOptions)

CookieStore.cs

Deletes a cookie (https://cookiestore.spec.whatwg.org/#dom-cookiestore-delete-options).

public Task Delete(CookieStoreDeleteOptions options)

Delete(string)

CookieStore.cs

Deletes the cookie with the name and the path / (https://cookiestore.spec.whatwg.org/#dom-cookiestore-delete).

public Task Delete(string name)

Get overloads

Get(CookieStoreGetOptions?)

CookieStore.cs

Returns the first script-visible cookie matching the options (https://cookiestore.spec.whatwg.org/#dom-cookiestore-get-options), or null.

public Task<CookieListItem?> Get(CookieStoreGetOptions? options = null)

Get(string)

CookieStore.cs

Returns the first script-visible cookie with the name (https://cookiestore.spec.whatwg.org/#dom-cookiestore-get), or null.

public Task<CookieListItem?> Get(string name)

GetAll overloads

GetAll(CookieStoreGetOptions?)

CookieStore.cs

Returns the script-visible cookies matching the options (https://cookiestore.spec.whatwg.org/#dom-cookiestore-getall-options).

public Task<IReadOnlyList<CookieListItem>> GetAll(CookieStoreGetOptions? options = null)

GetAll(string)

CookieStore.cs

Returns the script-visible cookies with the name (https://cookiestore.spec.whatwg.org/#dom-cookiestore-getall).

public Task<IReadOnlyList<CookieListItem>> GetAll(string name)

Set overloads

Set(CookieInit)

CookieStore.cs

Sets a cookie (https://cookiestore.spec.whatwg.org/#dom-cookiestore-set-options).

public Task Set(CookieInit options)

Set(string, string)

CookieStore.cs

Sets a cookie for the path /, Secure and SameSite=Strict (https://cookiestore.spec.whatwg.org/#dom-cookiestore-set).

public Task Set(string name, string value)