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 ?