Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to destroy session in client-sessions

If I am using client-sessions in NodeJS and wish to completely remove a session, how do I go about doing so? It seems that calling reset() just clears the session contents, effectively issuing a new session and updating the cookie with a new, extended expiry.

In this case, I wish to remove the session cookie altogether under certain circumstances (logout, etc.). Does anyone have any tips on how to do so?

like image 794
Brian Avatar asked Apr 11 '14 21:04

Brian


1 Answers

In a router like so...

router.get('/logout', function (req, res, next) {
    var session = require('client-sessions');
    req.session.reset();
    res.redirect('/login');
});
like image 167
Evin Weissenberg Avatar answered Sep 30 '22 12:09

Evin Weissenberg