Skip to content

is it possible to get httpOnly cookies in getServerSideProps? #17677

Discussion options

You must be logged in to vote

You should be able to like this:

export const getServerSideProps = async ctx => {
  // get the cookies
  const cookies = ctx.req.headers.cookie

  // set the cookies
  ctx.res.setHeader('Set-Cookie', 'foo=bar; HttpOnly');

  return { props: { } };
};

Replies: 5 comments 8 replies

Comment options

You must be logged in to vote
3 replies
@michaelwindell26
Comment options

@orloxx
Comment options

@jamesmosier
Comment options

Answer selected by jamesmosier
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@orloxx
Comment options

@nilsfast
Comment options

@MoltenCoffee
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@TylerOlthuizen
Comment options

@naimulemon
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
10 participants