Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

309
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda