flutter - 如何将过期时间添加到颤动的 Web cookie?
问题描述
我正在使用document.cookie将 cookie 存储在我的网络应用程序中。我想添加“过期”参数并设置 30 天后过期。我怎样才能做到这一点。
void _addToCookie(String key, String value) {
document.cookie = "$key=$value;expires=30";
}
解决方案
使用“max-age”参数而不是“expires”。"max-age" 需要秒;max-age=max-age-in-seconds(例如,60*60*24*365 或 31536000 为一年)
30 天 30×24×60×60 = 2592000。
void _addToCookie(String key, String value) {
document.cookie = "$key=$value; max-age=2592000;";
}
推荐阅读
- database - 将文件从 drupal 7 迁移到 drupal 8
- arm - arm-none-eabi 全局初始化变量值不正确
- android - RN 中类似于 Facebook 应用标头的动画
- spring - Spring Batch + Spring Boot + Couchbase
- angular - 我的问题是,模块“DashboardModule”导入的意外指令“BarChartComponent”。请添加@NgModule 注释
- postgresql - 翻译表的子查询出现错误
- sql-server - 使用副本数据库而不是使用启用 CDC 的数据库
- c++ - 在哪个访问控制上下文中评估概念?
- angular - 如何在组件角度4内单独刷新div
- node.js - 增加堆大小无效