I'm currently using node js and express to build a webapp.
I want to check when a user changes the page to check if he has a special cookie.
For this i tried :
server.on('request', (req, res)=>{`
console.log(req)
console.log(req.cookies)
console.log("\nCookie in serverCreate:\n")
console.log(req.cookies)
console.log("\nEnd Cookie in serverCreate:\n")
if(req.cookies["user"] == undefined || req.cookies["user"]==null || req.cookies["user"]==""){
res.redirect("/")
}
})
And I get this error:
TypeError: Cannot read property 'user' of undefined
And when I console.log(req)
, i get an big dictionary but with out cookies.
Thanks