Skip to content

Commit 7deedb2

Browse files
docs: Updating context.md with the latest cookies opts (#1433)
1 parent 3e97a10 commit 7deedb2

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

docs/api/context.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,15 @@ Koa uses the [cookies](https://github.com/pillarjs/cookies) module where options
7878

7979
Set cookie `name` to `value` with `options`:
8080

81-
- `maxAge` a number representing the milliseconds from Date.now() for expiry
82-
- `signed` sign the cookie value
83-
- `expires` a `Date` for cookie expiration
84-
- `path` cookie path, `'/'` by default
85-
- `domain` cookie domain
86-
- `secure` secure cookie
87-
- `httpOnly` server-accessible cookie, __true__ by default
88-
- `overwrite` a boolean indicating whether to overwrite previously set cookies of the same name (__false__ by default). If this is true, all cookies set during the same request with the same name (regardless of path or domain) are filtered out of the Set-Cookie header when setting this cookie.
81+
* `maxAge`: a number representing the milliseconds from `Date.now()` for expiry.
82+
* `expires`: a `Date` object indicating the cookie's expiration date (expires at the end of session by default).
83+
* `path`: a string indicating the path of the cookie (`/` by default).
84+
* `domain`: a string indicating the domain of the cookie (no default).
85+
* `secure`: a boolean indicating whether the cookie is only to be sent over HTTPS (`false` by default for HTTP, `true` by default for HTTPS). [Read more about this option](https://github.com/pillarjs/cookies#secure-cookies).
86+
* `httpOnly`: a boolean indicating whether the cookie is only to be sent over HTTP(S), and not made available to client JavaScript (`true` by default).
87+
* `sameSite`: a boolean or string indicating whether the cookie is a "same site" cookie (`false` by default). This can be set to `'strict'`, `'lax'`, `'none'`, or `true` (which maps to `'strict'`).
88+
* `signed`: a boolean indicating whether the cookie is to be signed (`false` by default). If this is true, another cookie of the same name with the `.sig` suffix appended will also be sent, with a 27-byte url-safe base64 SHA1 value representing the hash of _cookie-name_=_cookie-value_ against the first [Keygrip](https://www.npmjs.com/package/keygrip) key. This signature key is used to detect tampering the next time a cookie is received.
89+
* `overwrite`: a boolean indicating whether to overwrite previously set cookies of the same name (`false` by default). If this is true, all cookies set during the same request with the same name (regardless of path or domain) are filtered out of the Set-Cookie header when setting this cookie.
8990

9091
Koa uses the [cookies](https://github.com/pillarjs/cookies) module where options are simply passed.
9192

0 commit comments

Comments
 (0)