1

Say node express sessions are saved in an application (meaning they are not necessarily accessed from incoming req), how to check whether any of these sessions is expired? What is the proper test?

Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453
  • Put simply, you would just check whether or not the time between the created timestamp and now is larger than the ttl (or session duration). – Kevin B Oct 06 '14 at 18:24
  • Yeah of course, but what field in the session do I check and how? Do I have to check for nullity? – Jérôme Verstrynge Oct 06 '14 at 18:25
  • I guess that would depend on how the sessions are stored. For example, I store sessions in a database, and routinely remove expired sessions. I guess it all depends on what you are trying to do. Why do you need this information. – Kevin B Oct 06 '14 at 18:27
  • Precisely to remove them from the saving structure. It does not depend how they are saved, the information must be fetched from the session itself. – Jérôme Verstrynge Oct 06 '14 at 18:31

1 Answers1

-1

let's say you have saved User name in session. req.session.name='pankti' when you try to get it and if it is undefined then it is expired.req.session.name == 'undefined'