js-cookie设置token过期时间_详解ASP.NET Core Web Api之JWT刷新Token_实用技巧
时间: 2024-02-27 13:54:18
浏览: 56
好的,我了解您的问题。关于js-cookie设置token过期[时间](https://geek.csdn.net/educolumn/3fb26f40673739b3a46094a10b56bc3a?spm=1055.2569.3001.10083),我们可以通过设置cookie的expires属性来实现。示例[代码](https://geek.csdn.net/educolumn/1572ef9b473b4e00f6b2bf6d428b7c27?spm=1055.2569.3001.10083)如下:
// 设置cookie过期[时间](https://geek.csdn.net/educolumn/3fb26f40673739b3a46094a10b56bc3a?spm=1055.2569.3001.10083)为1小时
Cookies.set('token', 'your_token', { expires: 1/24 });
// 获取cookie过期时间
var expires = new Date(Cookies.[get](https://geek.csdn.net/educolumn/31aebce56f4ecc5451aac3a194ff6259?spm=1055.2569.3001.10083)('token')).toUTC[string](https://geek.csdn.net/edu/8802d631b97a4a6af1f4d0bbf8527465?dp_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6NDQ0MDg2MiwiZXhwIjoxNzA3MzcxOTM4LCJpYXQiOjE3MDY3NjcxMzgsInVzZXJuYW1lIjoid2VpeGluXzY4NjQ1NjQ1In0.RrTYEnMNYPC7AQdoij4SBb0kKEgHoyvF-bZOG2eGQvc&spm=1055.2569.3001.10083)();
console.log('token过期时间:' + expires);
```