I'm using express/nodejs to store sesssion logged-in to redis with the code:
app.use(express.session({
key: 'myappname.sid',
secret: "Some Secret!!!",
store : new RedisStore({
host : '127.0.0.1',,
port : 6379,
}),
cookie : {
maxAge : 604800 // one week
}
}));
I check logged in status by:
function ensureAuthenticated(req, res, next) {
if (req.isAuthenticated()) { return next(); }
res.redirect('/login')
}
When i loggin successfully, i saw the session of both chrome cookie and redis. But if i remove only one session on chrome cookie or redis, app will be no loggin status. Why does authenticating status depend on both chrome cookie and redis.
second question: I added domain like this
cookie : {
domain:"localhost", // or ".localhost"
maxAge : 604800 // one week
}
but when loggin successfully, no session store on chrome cookie, why this ?