Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add path for information in cookie setting #42146

Merged
merged 2 commits into from Nov 2, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/api-routes/request-helpers.md
Expand Up @@ -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
iAkashPattnaik marked this conversation as resolved.
Show resolved Hide resolved
setCookie(res, 'Next.js', 'api-middleware!', { path: '/', maxAge: 2419200 })
iAkashPattnaik marked this conversation as resolved.
Show resolved Hide resolved
// Return the `set-cookie` header so we can display it in the browser and show that it works!
res.end(res.getHeader('Set-Cookie'))
}
Expand Down