Node.js and Express session handling - Back button problem

后端 未结 4 1887
無奈伤痛
無奈伤痛 2020-12-23 19:04

I have a restricted area \'/dashboard\' in my Express application. I use a very small function to limit the access:

app.get(\'/dashboard\', loadUser, functi         


        
4条回答
  •  粉色の甜心
    2020-12-23 19:37

    Simple solution is after clearing the session .. again redirect to the same route.. for example: route /sessionedpage has session variables .. after clicking logout button clear session variables by req.session.destroy(function() {}); after that you are tring to redirect home page ... INSTEAD of redirecting to home page.. redirect /sessionedpage (same route) ... Write if condition for /sessionedpage if(!res.sessions) then res.redirect('/home')

提交回复
热议问题