I am a beginner working on a small user management project using NodeJS express. I did session handling and used nocache middleware on app level. When a user logs in, a session is created and when the user logs out the session is being destroyed, but still when I press the browser’s previous page button after the user logs out, it goes back to the previous page of which the session was destroyed. Why is this happening and How do I solve this?
I tried nocache middleware on app level to prevent caching. When a user logs in I created a new session (like req.session.user = userData), and destroyed it when the user logs out.
req.session.destroy(function(err) {
if(err) {
console.log(err);
res.send(err);
}
else {
res.redirect("/login?logout=Logout Successfully...");
}
});
Uvais is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.