Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

308
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!