Skip to Content
Node与Express开发(第2版)
book

Node与Express开发(第2版)

by Ethan Brown
June 2021
Intermediate to advanced
290 pages
9h 21m
Chinese
Posts & Telecom Press
Content preview from Node与Express开发(第2版)
Cookie
和
Session
|
93
secure
指定仅通过安全连接(
HTTPS
)发送此
Cookie
。
httpOnly
如果设为
true
,则指定这个
Cookie
只能由服务器端修改。也就是说,客户端
JavaScript
不能修改它。这样配置有助于避免
XSS
攻击。
signed
如果设为
true
,则指定这个
Cookie
进行签名,它会出现在
res.signedCookies
中,而
不是
res.cookies
中。签名
Cookie
如果被篡改,就会被服务器丢弃,
Cookie
值也会被
重置为初始值。
9.3
 查看
Cookie
出于测试的需要,很可能你希望有办法来检查系统中的
Cookie
。大多数浏览器可以查看
各个网站有哪些
Cookie
以及这些
Cookie
的值
。在
Chrome
中,打开开发者工具,选择
“
Application
”标签页
。在左侧列表中,你可以看到“
Cookies
”,展开它,就可以看到关联
当前网站的所有
Cookie
了
。可以右键单击域名,清除所有
Cookie
,或者右键单击某一条
Cookie
,只移除这一条。
9.4
 
Session
Session
其实是一种更方便的维护状态的方式。要实现
Session
,就必须在客户端存储
一些
信息,否则,服务器将不能从连续的请求中识别出这是同一个客户端。通常的做法是使用
一条包含唯一标识的
Cookie
,而服务器使用这个标识来获取相应的
Session
信息。
Cookie
不是实现
Session
的唯一办法
,在“
Cookie
恐慌”达到高峰的时候(那时
Cookie
滥用严重),很多用户只不过是关掉了 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

面向对象的思考过程(原书第5版)

面向对象的思考过程(原书第5版)

马特 魏斯费尔德
精通模块化JavaScript

精通模块化JavaScript

Nicolás Bevacqua

Publisher Resources

ISBN: 9787115565099