Express.js安全会话Cookie [英] Expressjs secure session cookie
本文介绍了Express.js安全会话Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我似乎找不到在expressjs框架中设置安全cookie的方法.是否可以在某个地方进行此操作?
I cant seem to find a way to set a secure cookie in expressjs framework. Is there an option to do this somewhere?
推荐答案
基于文档,请尝试这个:
res.cookie('rememberme', 'yes', { expires: new Date(Date.now() + 900000), httpOnly: true, secure: true });
使用res.cookie(name, val[, options])
将给定的cookie名称设置为val
,并带有选项httpOnly
,secure
,expires
等.path
选项默认为应用程序的basepath
设置,通常为"/"
.
Using res.cookie(name, val[, options])
sets the given cookie name to val
, with options httpOnly
, secure
, expires
, etc. The path
option defaults to the app’s basepath
setting, which is typically "/"
.
有关更多详细信息,请参见res.cookie
的文档.
See the docs for res.cookie
for more details.
这篇关于Express.js安全会话Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文