Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

279
Visualizações
How to use httpOnly on the client side when using jwt for authentication?

I understand how to set the cookie to be httpOnly on the server side when using express and jwt.

res.cookie("jwt", accessToken, { secure: true, httpOnly: true })

However how can we leverage the httpOnly on the client side to make the authentication process secure and prevent the cookie from being hijacked? Can you explain with an example please?

I am also trying to understand the difference between accessing a cookie when httpOnly is false and another cookie when httpOnly is true. I understand the latter will return empty string but where do we use it on the client side when using jwt for authentication. Should we just send an ajax call and not to bother about anything else?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You should not store JWT tokens directly in the cookie, as anyone looking at the cookies in the browser can steal the cookie. The cookie should be encrypted using strong encryption if you want to store it in the cookie.

HttpOnly will block JavaScript from accessing the cookie and it is best practice to always set in all important cookies. Also you should add the secure attribute to all cookies. Also do consider setting the SameSite attribute to make it even more secure.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda