I would like to run a function whenever a user’s session is destroyed/times out. Is there a way to do with in nodejs with express using a redis session store?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The session store’s themselves inherit from EventEmitter:
https://github.com/senchalabs/connect/blob/master/lib/middleware/session/store.js
Although none of the implementations emit events for you to bind to, including the redis store:
https://github.com/visionmedia/connect-redis/blob/master/lib/connect-redis.js
You could quite easily fork connect-redis and hack these events in yourself so that you may bind to them where you need to….
becomes
Then you may bind to the “destroy” event…