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

310
Visualizações
What is req.session._garbage = Date()?

Lets say I have:

app.use(
  session({
    store: new RedisStore({ client: redisClient, prefix: 'session' }),
    name: 'SID',
    secret: ['secret-xp'],
    resave: false,
    saveUninitialized: false,
    rolling: false,
    cookie: { path: '/', httpOnly: true, domain: 'localhost', secure: false, maxAge: 10000, sameSite: 'strict' },
  })
);

this type code.

max-age = 10 second | rolling = false

And lets say I want to reset the max-age of session when I hit the url withing 10 sec. I know that it is possible if I set rolling to true.

But there is one more way with req.session.touch();

The original documentation shows it's used with this kind of middleware.

app.use((req, res, next) => {
  req.session.touch();
  next();
});

But this doesn't work.

My research has shown that it is used as:

app.use((req, res, next) => {

  req.session._garbage = Date();

  req.session.touch();
  next();
});

This is working.

So question is what actually is req.session._garbage = Date(); and how it performs that ?

about 4 years ago · Juan Pablo Isaza
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