Nicekiwi
Nicekiwi

Reputation: 4807

Koa: How to get cookie's expiry date

I've setup a cookie with ctx.cookie.set('jwt', 'abcd', { expires: new Date(xxx) }), but now I need to grab that cookie again and get it's expiry date, how can I do that?

All the options I can see for ctx.cookie.get('jwt') only get the value of the cookie, not any of its options.

Upvotes: 2

Views: 1388

Answers (1)

Qyaffer
Qyaffer

Reputation: 220

There is no way to view the expiration date of a cookie. It simply will not exist in the cookies collection once it has expired. If you truly require the specific date of expiration, you could store it in a separate cookie.

Upvotes: 4

Related Questions