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")
}
})