Im using client-sessions and this is my code:
app.post("/login", (req, res)=>{
if (!req.session.activeUser){
User.findOne({username:req.body.username}).then(doc=>{
req.session.activeUser = req.body.username
res.send(req.session.activeUser + " Logged in successfully")
}).catch(e=>{
res.send(e)
})
}else {
res.redirect("/")
}
})
app.get("/logout", (req, res)=>{
req.session.reset()
res.redirect("/")
})
app.get("/online", (req, res)=>{
res.send(JSON.stringify(req.session))
console.log(JSON.stringify(req.session))
})
The response of /login
works well, but the controller /online
returns an empty object.
I've tried express-session and got the same problem
via BaHaa Jr.
No comments:
Post a Comment