I am setting a max age on the session cookie for an express session
app.use(session({ secret: process.env.EXPRESS_SECRET, key: 'sid', cookie: {secure: false, maxAge: 3000} }));
How can I use the event emitter, or custom events for express (which comes with an event emitter internally) - to fire an event when the session is ended and send data to the view layer?
Not sure I get what you want to achieve, but if you want to check the session has ended, you could just set a session data
Otherwise, you could easily implement your own session store which would inherit the store of your choice (by default the express memory store which also inherits EventEmitter) and override the method
#destroy
which resets the session: