Skip to content

Commit 8c1e4b3

Browse files
docs: update res.clearCookie documentation for clarity and accuracy (#2000)
Improve the message by expanding on how the cookie is cleared, and include a note about the deprecation of the `max-age` and `expires` options: in Express 4 they are still respected (not ignored), whereas in Express 5 they are ignored. ref: expressjs/express#5792 ref: expressjs/express#5640 ref: expressjs/express#5672 closes: #1146 Note: We need to manage changes more effectively. Whenever there are changes, and once they have been released, a PR should be opened here to update the documentation. Improving these processes will help us keep our documentation better maintained. Signed-off-by: Sebastian Beltran <[email protected]> Co-authored-by: ShubhamOulkar <[email protected]>
1 parent 10929d3 commit 8c1e4b3

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

_includes/api/en/4x/res-clearCookie.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<h3 id='res.clearCookie'>res.clearCookie(name [, options])</h3>
22

3-
Clears the cookie specified by `name`. For details about the `options` object, see [res.cookie()](#res.cookie).
3+
Clears the cookie with the specified `name` by sending a `Set-Cookie` header that sets its expiration date in the past.
4+
This instructs the client that the cookie has expired and is no longer valid. For more information
5+
about available `options`, see [res.cookie()](#res.cookie).
6+
7+
<div class="doc-box doc-warn" markdown="1">
8+
If the `maxAge` or `expires` options are set, the cookie may not be cleared depending on the time values provided,
9+
as Express does not ignore these options. It is therefore recommended to omit these options when calling this
10+
method. Passing these two options has been deprecated since Express v4.20.0.
11+
</div>
412

513
<div class="doc-box doc-notice" markdown="1">
614
Web browsers and other compliant clients will only clear the cookie if the given

_includes/api/en/5x/res-clearCookie.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
<h3 id='res.clearCookie'>res.clearCookie(name [, options])</h3>
22

3-
Clears the cookie specified by `name`. For details about the `options` object, see [res.cookie()](#res.cookie).
3+
Clears the cookie with the specified `name` by sending a `Set-Cookie` header that sets its expiration date in the past.
4+
This instructs the client that the cookie has expired and is no longer valid. For more information
5+
about available `options`, see [res.cookie()](#res.cookie).
6+
7+
<div class="doc-box doc-notice" markdown="1">
8+
The `expires` and `max-age` options are being ignored completely.
9+
</div>
410

511
<div class="doc-box doc-notice" markdown="1">
612
Web browsers and other compliant clients will only clear the cookie if the given
7-
`options` is identical to those given to [res.cookie()](#res.cookie), excluding
8-
`expires` and `maxAge`.
13+
`options` is identical to those given to [res.cookie()](#res.cookie)
914
</div>
1015

1116
```js

0 commit comments

Comments
 (0)