express4 session 不会用。以前用过express3 很不错。换了新就不行。粘出代码
app.use(cookieParser()); app.use(session({
keys: [‘key1’, ‘key2’],
secureProxy: true }));
app.use(function(req,res,next){ var again = req.query.again||false;
var n = req.session.views || 0
req.session.views = ++n
***console.log(n); // n 值永远是1 ***
if(req.session.curruser){
res.render(‘login/loginsuccess’,{loginname:loginname,password:password});
}
else{
res.render(‘login/login’,{again:again});
};
})
app.listen(3000);