From bf8ddd563fece8bfda09df930e4f3be32acc1cd8 Mon Sep 17 00:00:00 2001 From: AkashPattanaik Date: Sun, 30 Oct 2022 00:01:14 +0530 Subject: [PATCH 1/2] Add `path` for information --- docs/api-routes/request-helpers.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/api-routes/request-helpers.md b/docs/api-routes/request-helpers.md index 28be26d66cf4..ee356e7d6709 100644 --- a/docs/api-routes/request-helpers.md +++ b/docs/api-routes/request-helpers.md @@ -128,7 +128,8 @@ import { setCookie } from '../../utils/cookies' const handler = (req: NextApiRequest, res: NextApiResponse) => { // Calling our pure function using the `res` object, it will add the `set-cookie` header - setCookie(res, 'Next.js', 'api-middleware!') + // The path option here sets the cookie on the main domain and maxAge option sets the cookie to expire after 30 days + setCookie(res, 'Next.js', 'api-middleware!', { path: '/', maxAge: 2419200 }) // Return the `set-cookie` header so we can display it in the browser and show that it works! res.end(res.getHeader('Set-Cookie')) } From 8ba642ffc2e928e90a2cfd090b25581489e6621d Mon Sep 17 00:00:00 2001 From: AkashPattanaik Date: Tue, 1 Nov 2022 16:03:18 +0530 Subject: [PATCH 2/2] update wording and `maxAge` for 30 days --- docs/api-routes/request-helpers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api-routes/request-helpers.md b/docs/api-routes/request-helpers.md index ee356e7d6709..3a3f6a0e83e6 100644 --- a/docs/api-routes/request-helpers.md +++ b/docs/api-routes/request-helpers.md @@ -128,8 +128,8 @@ import { setCookie } from '../../utils/cookies' const handler = (req: NextApiRequest, res: NextApiResponse) => { // Calling our pure function using the `res` object, it will add the `set-cookie` header - // The path option here sets the cookie on the main domain and maxAge option sets the cookie to expire after 30 days - setCookie(res, 'Next.js', 'api-middleware!', { path: '/', maxAge: 2419200 }) + // Add the `set-cookie` header on the main domain and expire after 30 days + setCookie(res, 'Next.js', 'api-middleware!', { path: '/', maxAge: 2592000 }) // Return the `set-cookie` header so we can display it in the browser and show that it works! res.end(res.getHeader('Set-Cookie')) }