简体   繁体   English

Koa:如何获取Cookie的到期日期

[英]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? 我已经使用ctx.cookie.set('jwt', 'abcd', { expires: new Date(xxx) })设置了一个cookie,但是现在我需要再次抓取该cookie并获取它的到期日期,我该怎么办?去做?

All the options I can see for ctx.cookie.get('jwt') only get the value of the cookie, not any of its options. 我为ctx.cookie.get('jwt')看到的所有选项仅获取cookie的值,而不获取其任何选项。

There is no way to view the expiration date of a cookie. 无法查看Cookie的到期日期。 It simply will not exist in the cookies collection once it has expired. 一旦过期,它就根本不会存在于cookie集合中。 If you truly require the specific date of expiration, you could store it in a separate cookie. 如果您确实需要特定的到期日期,则可以将其存储在单独的Cookie中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM