I have a Backbone View that sends an Ajax call to a server to delete a session.
The following event is fired on the server:
app.delete('/session', function(req, res) { if (req.session) { req.session.destroy(function() { res.clearCookie('connect.sid', { path: '/' }); res.send('removed session', 200); }); } else { res.send('no session assigned', 500); } });
It is strange that I can press the logout button several times without receiving an HTTP 500 error code. Also chrome shows me that the cookie still exists.
What is going wrong?
Hi
EDIT
I found out that this is not a session problem, but a cookie. I added res.clearCookie to the route. Unfortunately, the behavior (cookie, session keep alive) has not changed
EDIT2 : I now gave res.clearCookie some parameters => res.clearCookie ('connect.sid', {path: '/'}); Now at least the cookie has disappeared in the browser. But the session seems to be still available. Or at least I can call the logout route, how often do I want even req.session to be false
EDIT3: Now I deleted all sessions from redis and restarted everything (redis, node, browser). Than I logged in again and logged out. This still works, but when I reset the page with F5, I get a new session. Why?
source share