Dail
Dail

Reputation: 4606

How to get the expiration timestamp of a session?

I'm using Node.JS and Express web framework, I need to work with Sessions.

I would get the expiration timestamp of the session, is this possible?

I would like to know when(timestamp format) the session expires.

Thank you!

Upvotes: 1

Views: 949

Answers (1)

alessioalex
alessioalex

Reputation: 63663

From the official Connect docs, session middleware page (Express uses Connect internally):

Session#maxAge

Alternatively req.session.cookie.maxAge will return the time remaining in milliseconds, which we may also re-assign a new value to adjust the .expires property appropriately. The following are essentially equivalent

So req.session.cookie.maxAge is what you're looking for.

Upvotes: 2

Related Questions