diff --git a/docs/api-routes/api-middlewares.md b/docs/api-routes/api-middlewares.md index 1815a1192dea8..4bd29a3e933fb 100644 --- a/docs/api-routes/api-middlewares.md +++ b/docs/api-routes/api-middlewares.md @@ -165,9 +165,8 @@ export const setCookie = ( const stringValue = typeof value === 'object' ? 'j:' + JSON.stringify(value) : String(value) - if ('maxAge' in options) { - options.expires = new Date(Date.now() + options.maxAge) - options.maxAge /= 1000 + if (typeof options.maxAge === 'number') { + options.expires = new Date(Date.now() + options.maxAge * 1000) } res.setHeader('Set-Cookie', serialize(name, stringValue, options))