קורס Node.JS שיעור פיתוח דפי כניסה והרשמה


זה נושא דיון מלווה לערך המקורי ב- https://www.tocode.co.il/bundles/nodejs/lessons/46-login-signup

Hi Ynon!

.Regarding terminating session in logout route.
I made the whole process and got the userid shown on
http://localhost:3000/
I took example code

/**
 * C:\Users\papaa>curl -X POST http://localhost:3000/sessions/logout
 */
router.post('/logout', function(req, res, next) {
    req.session.userid = null;
    console.log("session terminated");
    console.log(req.session);
    res.redirect('/');
});

I hit it with
curl -X POST http://localhost:3000/sessions/logout
it hits yet when refreshing
http://localhost:3000/
I still get the same user despite the session should be deleted.
I tried to google yet didn’t find proper solution, the session doesn’t terminate.
Does it work for you?
Thanks

Hi @avrahamm

You’re trying to logout using curl, but the session is identified by a session cookie,
and curl does not send this session cookie (as it’s saved in the browser)