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

150
Visualizações
Node.js - Should I refresh cookie with each request/response to update expiration time?

Authentication method

In my Node.js (w/ Express.js) back-end, I authenticate users using JWT that is stored in a cookie with HttpOnly flag. The cookie expires in N hours. A middleware checks if JWT is valid and either calls next() function or sends a 401 status.

Current behavior

If cookie expires, user must log in again, even if he was still using the app.

Desired behavior

I want the cookie to expire in N hours but as long as user is using the app, expiration time must be updated. User should log in again only if N hours have passed from the last time he interacted with the app.

Question

Should I send a new cookie with each response, even if the only thing that changes is expiration time? Is this considered a good practice?

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

0

what you need is called refresh-token

you can find more detail about refresh tokens on:

https://www.rfc-editor.org/rfc/rfc6749#section-1.5 and https://developer.okta.com/docs/guides/refresh-tokens/main/

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