gpt4 book ai didi

node.js - 如何在 express 中设置单个 session maxAge?

转载 作者:IT老高 更新时间:2023-10-28 22:03:00 31 4
gpt4 key购买 nike

我了解到您可以在启动应用程序时设置 maxAge 如下:

connect.session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }})

但是,我想按照“记住我”设置的方式实现一些东西,我该怎么做呢?

非常感谢:)

杰森

最佳答案

您可以在属于当前用户的单个 cookie 上设置 expiresmaxAge:

// This user should log in again after restarting the browser
req.session.cookie.expires = false;

// This user won't have to log in for a year
req.session.cookie.maxAge = 365 * 24 * 60 * 60 * 1000;

connect session documentation .

关于node.js - 如何在 express 中设置单个 session maxAge?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9714785/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com