Answer the question
In order to leave comments, you need to log in
How to delete a session after closing the browser?
Hey! I use
const session = require('express-session');
const MongoStore = require('connect-mongodb-session')(session);
const store = new MongoStore({
collection: 'sessions',
uri: process.env.MONGODB_URI
})
app.use(session({
secret: process.env.SECRET,
resave: false,
saveUninitialized: false,
store,
}))
router.post('/signin', async (req, res) => {
//...
req.session.user = candidate;
req.session.cookie.expires = false;
req.session.isAuthenticated = true;
req.session.save(err => {
if (err) {
req.flash('error', err)
res.redirect('/user/signin')
}
//...
})
{
path: '/',
_expires: false,
originalMaxAge: false,
httpOnly: true,
secure: null,
domain: null,
sameSite: null
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question