forked from mdn/content
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
69 lines (51 loc) · 2.34 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
title: CookieStore.delete()
slug: Web/API/CookieStore/delete
tags:
- API
- Method
- Reference
- delete()
- CookieStore
browser-compat: api.CookieStore.delete
---
<div>{{securecontext_header}}{{DefaultAPISidebar("Cookie Store API")}}</div>
<p>The <strong><code>delete()</code></strong> method of the {{domxref("CookieStore")}} interface deletes a cookie with the given name or options object. (See below.) The <code>delete()</code> method expires the cookie by changing the date to one in the past.</p>
<h2 id="Syntax">Syntax</h2>
<pre class="syntaxbox">var <var>promise</var> = cookieStore.delete(<var>name</var>);
var <var>promise</var> = cookieStore.delete(<var>options</var>);</pre>
<h3 id="Parameters">Parameters</h3>
<p>This method requires one of the following:</p>
<dl>
<dt><code>name</code></dt>
<dd>A {{domxref("USVString")}} with the name of a cookie.</dd>
<dt>options</dt>
<dd>An object containing:
<dl>
<dt><code>name</code></dt>
<dd>A {{domxref("USVString")}} with the name of a cookie.</dd>
<dt><code>url</code>{{Optional_Inline}}</dt>
<dd>A {{domxref("USVString")}} with the url of a cookie.</dd>
<dt><code>path</code>{{Optional_Inline}}</dt>
<dd>A {{domxref("USVString")}} containing a path.</dd>
</dl>
</dd>
</dl>
<div class="notecard note">
<p><strong>Note:</strong> The <code>url</code> option enables the modification of a cookie scoped under a particular URL. Service workers can obtain cookies that would be sent to any URL under their scope. From a document you may only obtain the cookies at the current URL, so the only valid URL in a document context is the document's URL.</p>
</div>
<h3 id="Returns">Return value</h3>
<p>A {{jsxref("Promise")}} that resolves with {{jsxref("Undefined")}} when deletion completes.</p>
<h3 id="Exceptions">Exceptions</h3>
<dl>
<dt>{{jsxref("TypeError")}}</dt>
<dd>Thrown if deleting the cookie represented by the given <code>name</code> or <code>options</code> fails.</dd>
</dl>
<h2 id="Examples">Examples</h2>
<p>In this example a cookie is deleted by passing the name to the <code>delete()</code> method.</p>
<pre class="brush: js">let result = cookieStore.delete('cookie1');
console.log(result);</pre>
<h2 id="Specifications">Specifications</h2>
{{Specifications}}
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{Compat}}</p>