Unverified Commit 3674cada authored by Sagnik Chatterjee's avatar Sagnik Chatterjee Committed by GitHub

docs: adding changes to setCookie example (#36870)

fixes #28453

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [X] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [X] Make sure the linting passes by running `yarn lint`
parent 2b88467d
...@@ -165,9 +165,8 @@ export const setCookie = ( ...@@ -165,9 +165,8 @@ export const setCookie = (
const stringValue = const stringValue =
typeof value === 'object' ? 'j:' + JSON.stringify(value) : String(value) typeof value === 'object' ? 'j:' + JSON.stringify(value) : String(value)
if ('maxAge' in options) { if (typeof options.maxAge === 'number') {
options.expires = new Date(Date.now() + options.maxAge) options.expires = new Date(Date.now() + options.maxAge * 1000)
options.maxAge /= 1000
} }
res.setHeader('Set-Cookie', serialize(name, stringValue, options)) res.setHeader('Set-Cookie', serialize(name, stringValue, options))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment