I have a simple app that uses node for the backend. Whenever a user signs in, I use a cookie to store the session, and when they sign out, I delete that cookie, also, I use ejs to display certain data to the user (like their user name).
The problem is that, for whatever reason, when I enter a view without being signed in (example, the index page), after signing in, that view is presented as if I wasn´t sign in (example, the user name is not present), but other views are present as if I was (the cookie is there in both cases); also, after signing out, the views that I rendered while being signing in, are still presented as if I was, while the other are not (and in this case, the cookie is not present).
I may assume that is something to do with how node/ejs/browsers render things, that there may store something in a cache, and they don´t even bother to ask for it again (after signing in/out), but this breaks all the front´s login, since it assumes that the user is singed in/out when it is not.
What can I do to force to reload the view, and thus, check if what I explained this what is happening?
Edit: my logout code is as follows:
backend:
router.get('/logOut',verifiyLogin, async (req, res) =>{
res.clearCookie('cookie');
return res.status(200).send();
});
frontend;
$.ajax({
url: url+"/logOut",
type: "get",
success: function(response) {
window.location.assign('/');
},
error: function(xhr) {
alert('Error: '+xhr.response);
}
});