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

125
Visualizações
Is it possible to set cookies to never expire for express-session?

Is it possible to set cookies to never expire for express-session? If not is there a maximum maxAge?

I found some documentation on how to set the cookie expiration here on SO ( 10+ years old ) and here on express. However; this is for a specified time of 1 year.

Is it possible to never have it expire and if so how?

My config looks like this where maxAge is now set to default as follows:

const options = {
  // ... snip
  resave: false,
  saveUninitialized: true,
  cookie:{
    maxAge: null
  },
  store: new RedisStore({ client: RedisClient })
};

As a side what is the default maxAge?

According to the docs the default (null) should not be persistent, but if I leave the value at null they are still persisting for some time.

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

0

According to Section 5.3.3 of the cookie spec, if you do not specify a MaxAge or Expires header at all, the user agent will set the cookie to expire at the latest date it can represent (= the maximum integer it can store) which is pretty much inifinite. However, this will set the cookie's persistent flag to false, meaning that the cookie is never stored on the disk and therefore will be deleted the moment the browser closes.

What prevents you from just setting the expiration date to some point way in the future though? 10 years? Maybe 100 years? I don't think you'll ever need to persist a session cookie that long

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