How to end a session in ExpressJS


I feel like this has to be buried somewhere in the documentation, but I can't find it.

How do you close or end or kill (whatever) a session in ExpressJS?

12/1/2011 10:18:36 PM

Accepted Answer

Express 4.x Updated Answer

Session handling is no longer built into Express. This answer refers to the standard session module:

To clear the session data, simply use:


The documentation is a bit useless on this. It says:

Destroys the session, removing req.session, will be re-generated next request. req.session.destroy(function(err) { // cannot access session here })

This does not mean that the current session will be re-loaded on the next request. It means that a clean empty session will be created in your session store on next request. (Presumably the session ID isn't changing, but I have not tested that.)

4/14/2015 5:23:56 AM

Never mind, it's req.session.destroy();

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow