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.
Constructors
CookieStore()
public CookieStore()
Properties
Onchange
[Value("onchange")]
public EventHandlerNonNull Onchange { get; set; }
Property Value
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
optionsCookieStoreDeleteOptions
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.
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
namestring
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.
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
optionsCookieStoreGetOptions
Returns
- Task<CookieListItem>
A Promise that resolves with an object representing the first cookie matching the submitted
nameoroptions, ornullif 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
namestring
Returns
- Task<CookieListItem>
A Promise that resolves with an object representing the first cookie matching the submitted
nameoroptions, ornullif 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
optionsCookieStoreGetOptions
Returns
- Task<List<CookieListItem>>
A Promise that resolves with an array of objects representing cookies that match the given
nameoroptions.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
namestring
Returns
- Task<List<CookieListItem>>
A Promise that resolves with an array of objects representing cookies that match the given
nameoroptions.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
optionsCookieInit
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
Returns
- Task<GlobalObject.Undefined>
A Promise that resolves with GlobalObject.Undefined when setting the cookie completes.