标签:console session first 分享图片 ack set ++ mongodb .com
First
npm i express-session
var expressSession = require("express-session");
app.use(expressSession({
secret:‘adsadsadsadsads‘,
resave:true,
saveUninitialized:true,
cookie:{maxAge:3600000}))
app.get("setsession",function(req,res){
console.log(req.session);
console.log(req.session.cookie)
if(req.session.pageViews){
req.session.pageViews++;
req.session.abc=123;
res.send("you viewed"+req.session.pageViews)
}else{
req.session.pageViews=1;
res.send("one time")
}
})
Reference:
https://www.npmjs.com/package/express-session
标签:console session first 分享图片 ack set ++ mongodb .com
原文地址:https://www.cnblogs.com/cyany/p/9968549.html