使用护照js和快速会话登录是可以的,但是当尝试添加会话(例如req.session.views)时,该会话将计算用户在我的博客上的访问次数,不幸的是,该会话将仅查看此用户的访问方式它的意见。
我的问题是我想在所有管理员用户中设置req.session.views。
app.use(session({
secret: "secret",
resave: false,
saveUninitialized: false,
store: new MongoStore({ mongooseConnection: mongoose.connection}),
cookie: { maxAge: new Date(Date.now() + 315360000000)}
}));
app.use(function(req, res, next){
res.locals.currentUser = req.user;
res.locals.error = req.flash("error");
res.locals.success = req.flash("success");
res.locals.session = req.session;
next();
});
app.get('/', function(req, res){
if(req.session.views){
req.session.views++;
res.render('/index');
}else{
req.session.views = 1;
res.render('/index');
});