博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用Express管理Cookies
阅读量:2505 次
发布时间:2019-05-11

本文共 1086 字,大约阅读时间需要 3 分钟。

Use the Response.cookie() method to manipulate your cookies.

使用Response.cookie()方法来操作您的cookie。

Examples:

例子:

res.cookie('username', 'Flavio')

This method accepts a third parameter, which contains various options:

此方法接受第三个参数,其中包含各种选项:

res.cookie('username', 'Flavio', { domain: '.flaviocopes.com', path: '/administrator', secure: true })res.cookie('username', 'Flavio', { expires: new Date(Date.now() + 900000), httpOnly: true })

The most useful parameters you can set are:

您可以设置的最有用的参数是:

Value Description
domain The
expires Set the . If missing, or 0, the cookie is a session cookie
httpOnly Set the cookie to be accessible only by the web server. See
maxAge Set the expiry time relative to the current time, expressed in milliseconds
path The . Defaults to ‘/’
secure Marks the
signed Set the cookie to be signed
sameSite Value of
描述
domain
expires 设置 。 如果丢失或为0,则该cookie是会话cookie
httpOnly 将cookie设置为只能由Web服务器访问。 参见
maxAge 设置相对于当前时间的到期时间,以毫秒为单位
path 。 默认为'/'
secure 将标记为
signed 设置要签名的cookie
sameSite 价值

A cookie can be cleared with:

Cookie可以通过以下方式清除:

res.clearCookie('username')

翻译自:

转载地址:http://uxqgb.baihongyu.com/

你可能感兴趣的文章
ionic2 native app 更新用户头像暨文件操作
查看>>
SQL Server R2 地图报表制作(一)
查看>>
ZeroMQ——一个轻量级的消息通信组件
查看>>
JavaScript中数组和json的复制
查看>>
C语言多线程编程二
查看>>
转载:从集群计算到云计算
查看>>
服务器文件管理
查看>>
作业2
查看>>
ios上架报错90080,90087,90209,90125 解决办法
查看>>
给button添加UAC的小盾牌图标
查看>>
如何退出 vim
查看>>
Robberies
查看>>
get post 提交
查看>>
R安装
查看>>
跟我一起学C++
查看>>
Android自动化测试之环境搭建
查看>>
JavaScript运算符
查看>>
html position布局
查看>>
VTP
查看>>
Linux内核分析第一周——计算机是如何工作的
查看>>