惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
D
Docker
Vercel News
Vercel News
IT之家
IT之家
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
腾讯CDC
Google DeepMind News
Google DeepMind News
I
InfoQ
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
博客园 - Franky
The Cloudflare Blog
A
About on SuperTechFans
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
T
Tenable Blog
P
Proofpoint News Feed
Recorded Future
Recorded Future
Security Latest
Security Latest
H
Hackread – Cybersecurity News, Data Breaches, AI and More
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 聂微东
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google Online Security Blog
Google Online Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Simon Willison's Weblog
Simon Willison's Weblog
The Last Watchdog
The Last Watchdog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
U
Unit 42
The Hacker News
The Hacker News
Martin Fowler
Martin Fowler
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
F
Full Disclosure
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
Project Zero
Project Zero

博客园 - 匡匡

Vue 父子组件通信方式 Vue: 组件扩展 WebClient 指定出口 IP IIS8 下 JS, CSS 等静态文件出现 500 错误 使用 ffmpeg 转换 mov 视频 使用 ildasm 和 ilasm 修改程序集的的引用信息 2020-01-08 工作日记:无题 .Net Core 程序集管理说明(加载) .NET CORE 动态加载 DLL 的问题 使用 sql server 默认跟踪分析执行的 SQL 语句 Nginx深入详解之upstream分配方式 使用 HttpWebRequest 类做 POST 请求没有应反 webpack 里的 import, exports 实现原理 使用 pdf.js 查看发票时,显示不了台头和印章的解决办法 Flex 布局里 input 宽度最小 150px 的问题, 浏览器 BUG? 使用像素单位设置 EXCEL 列宽或行高 sweetalert 快速显示两个提示, 第二个显示不出的问题 加权轮询和加权随机算法 在 Docker 中部署 ASP.NET CORE 应用
ASP.NET 后台 COOKIE 的设置
匡匡 · 2019-11-20 · via 博客园 - 匡匡

这几年经常与安全打交道,深知 COOKIE 对一个网站的安全影响有多大,所以在编写相与 cookie 相关代码的时候,都会特别的小心。

最近做一个系统,有几个地方用到 cookie, 然后统一把 cookie 的几个属性都设置为自己认为最安全的状态: httponly: true, secure: true, samesite: strict。

然后发现,在使用 ajax 请求的时候, 服务器端服务了 cookie (有 set-cookie 头),但是再请求其他页面时,发现通过 ajax 请求设置的 cookie 都没有带过去, 通过开发者工具查看网站下面的 cookie,发现里面也没有。然后把同样的代码,放到一个普通的请求页面,发现设置的 cookie 又没有问题。

经过不断的测试,终于发现是 path 和 secure 引起的问题, 因为在本地测试,所以是使用 http, 这个时候把 secure 设置为 true, 通过 ajax 请求设置的 cookie 不会设置到网站,还有一个就是 path, 之前没有设置,导致 cookie 也不生效,最终把 secure 设置为 false, path 设置为 / 就好了。