Table of Contents

Class CookieStore

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The CookieStore interface of the {{domxref("Cookie Store API", "", "", "nocode")}} provides methods for getting and setting cookies asynchronously from either a page or a service worker.

[Value("CookieStore")]
public class CookieStore : EventTarget
Inheritance
CookieStore
Inherited Members

Remarks

The CookieStore is accessed via attributes in the global scope in a Window or ServiceWorkerGlobalScope context. Therefore there is no constructor.

See also on MDN

Constructors

CookieStore()

public CookieStore()

Properties

Onchange

[Value("onchange")]
public EventHandlerNonNull Onchange { get; set; }

Property Value

EventHandlerNonNull

Methods

Delete(CookieStoreDeleteOptions)

The delete() method of the CookieStore interface deletes a cookie that matches the given name or options object.
The method expires the cookie by changing its date to one in the past.

[Value("delete")]
public Task<GlobalObject.Undefined> Delete(CookieStoreDeleteOptions options)

Parameters

options CookieStoreDeleteOptions

Returns

Task<GlobalObject.Undefined>

A Promise that resolves with GlobalObject.Undefined when the deletion operation completes or no cookie is matched.

Remarks

Note that there is no error if a cookie cannot be matched: the returned promise will fulfill when the matched cookie is deleted or if no cookie is matched.

See also on MDN

Delete(string)

The delete() method of the CookieStore interface deletes a cookie that matches the given name or options object.
The method expires the cookie by changing its date to one in the past.

[Value("delete")]
public Task<GlobalObject.Undefined> Delete(string name)

Parameters

name string

Returns

Task<GlobalObject.Undefined>

A Promise that resolves with GlobalObject.Undefined when the deletion operation completes or no cookie is matched.

Remarks

Note that there is no error if a cookie cannot be matched: the returned promise will fulfill when the matched cookie is deleted or if no cookie is matched.

See also on MDN

Get(CookieStoreGetOptions)

The get() method of the CookieStore interface returns a {{jsxref("Promise")}} that resolves to a single cookie matching the given name or options object. The method will return the first cookie that matches.

[Value("get")]
public Task<CookieListItem?> Get(CookieStoreGetOptions options = null)

Parameters

options CookieStoreGetOptions

Returns

Task<CookieListItem>

A Promise that resolves with an object representing the first cookie matching the submitted name or options, or null if there is no matching cookie.The object returned for a match contains the following properties:

Remarks

Get(string)

The get() method of the CookieStore interface returns a {{jsxref("Promise")}} that resolves to a single cookie matching the given name or options object. The method will return the first cookie that matches.

[Value("get")]
public Task<CookieListItem?> Get(string name)

Parameters

name string

Returns

Task<CookieListItem>

A Promise that resolves with an object representing the first cookie matching the submitted name or options, or null if there is no matching cookie.The object returned for a match contains the following properties:

Remarks

GetAll(CookieStoreGetOptions)

The getAll() method of the CookieStore interface returns a {{jsxref("Promise")}} that resolves as an array of cookies that match the name or options passed to it.
Passing no parameters will return all cookies for the current context.

[Value("getAll")]
public Task<List<CookieListItem>> GetAll(CookieStoreGetOptions options = null)

Parameters

options CookieStoreGetOptions

Returns

Task<List<CookieListItem>>

A Promise that resolves with an array of objects representing cookies that match the given name or options.Each object contains the following properties:

Remarks

GetAll(string)

The getAll() method of the CookieStore interface returns a {{jsxref("Promise")}} that resolves as an array of cookies that match the name or options passed to it.
Passing no parameters will return all cookies for the current context.

[Value("getAll")]
public Task<List<CookieListItem>> GetAll(string name)

Parameters

name string

Returns

Task<List<CookieListItem>>

A Promise that resolves with an array of objects representing cookies that match the given name or options.Each object contains the following properties:

Remarks

Set(CookieInit)

The set() method of the CookieStore interface sets a cookie with the given name and value or options object.

[Value("set")]
public Task<GlobalObject.Undefined> Set(CookieInit options)

Parameters

options CookieInit

Returns

Task<GlobalObject.Undefined>

A Promise that resolves with GlobalObject.Undefined when setting the cookie completes.

Remarks

Set(string, string)

The set() method of the CookieStore interface sets a cookie with the given name and value or options object.

[Value("set")]
public Task<GlobalObject.Undefined> Set(string name, string value)

Parameters

name string
value string

Returns

Task<GlobalObject.Undefined>

A Promise that resolves with GlobalObject.Undefined when setting the cookie completes.

Remarks