当前位置:网站首页>Chrome 配置samesite=none方式
Chrome 配置samesite=none方式
2022-07-30 21:20:00 【Ajekseg】
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
文章目录
前言
Chrome从70版本开始,出现了所谓的同源策略问题。80版本开始默认SameSite=Lax,导致跨域Cookie传输收到限制。
我们遇到的问题是:从其他网站跳转回来的时候,地址栏在正常地址的基础上出现了JSESSIONID=XXXXXXXXX,导致原有session失效。
二、解决方案
1.方案一:修改浏览器配置
此方式比较粗暴,直接将浏览器的SameSite的属性设置回到以前的None状态。但缺点是每台客户端机器都需要配置,适用于用户范围可控的情景。
据说从91版本开始,此方式失效,未进行测试。。。。
1)chrome地址栏输入chrome://flags
2)通过禁用“SameSite by default cookies”和“Cookies without SameSite must be secure”功能开关
3)重新启动浏览器
方式2和方式3是设置samesite=none,且显式声明secure=true,只支持https且samesite=none的情况下跨域携带cookie。
2.方案二:使用Nginx
# 设置一个变量,用于判断是否增加SameSite=None属性
set $cookiePathMagicFlag '';
# 00~69 之间Chrome, 设置为-evil'
if ($http_user_agent ~ "Chrome/([0-6][0-9].)"){
set $cookiePathMagicFlag '-evil';
}
location / {
# nginx其他配置
# xxxxxxxxx
# 增加SameSite=None、secure配置
proxy_cookie_path /$cookiePathMagicFlag "/; httponly; secure; SameSite=None";
}
3.方案三:若服务器为Tomcat,可使用以下方式(Tomcat8.5.x以上版本)
修改conf/context.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- The contents of this file will be loaded for each web application -->
<Context>
<!-- Default set of monitored resources. If one of these changes, the -->
<!-- web application will be reloaded. -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<!-- 配置sameSiteCookies=None -->
<CookieProcessor sameSiteCookies ="None" />
</Context>
先自我介绍一下,小编13年上师交大毕业,曾经在小公司待过,去过华为OPPO等大厂,18年进入阿里,直到现在。深知大多数初中级java工程师,想要升技能,往往是需要自己摸索成长或是报班学习,但对于培训机构动则近万元的学费,着实压力不小。自己不成体系的自学效率很低又漫长,而且容易碰到天花板技术停止不前。因此我收集了一份《java开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦
边栏推荐
- [Nuxt 3] (十三) Nuxt 是如何工作的?
- [Deep Learning] Target Detection | SSD Principle and Implementation
- WeChat reading, export notes
- 大家都在用的plm项目管理软件有哪些
- MySQL60 homework
- Deep Non-Local Kalman Network for VideoCompression Artifact Reduction
- [Limited Time Bonus] 21-Day Learning Challenge - MySQL from entry to mastery
- 三层架构简单配置
- 牛客网——业务分析-提取值
- 外包干了三年,废了...
猜你喜欢

Enhancing Quality for HEVC Compressed Videos

MySQL笔记1(数据库的好处,数据库的概念,数据库的特点,MySQL的启动,数据模型,SQL)

【机器学习】梯度下降背后的数学之美

Outsourcing worked for three years, it was abolished...

vlan简单实验

WeChat reading, export notes

Niu Ke Xiaobaiyue Race 53 A-E

基于ABP实现DDD--领域服务、应用服务和DTO实践

系统结构考点之多级混洗交换网络

Automatically generate test modules using JUnit4 and JUnitGenerator V2.0 in IDEA
随机推荐
Why do so many people who teach themselves software testing give up later...
系统结构考点之流水线向量点积
[Limited Time Bonus] 21-Day Learning Challenge - MySQL from entry to mastery
Deep Non-Local Kalman Network for VideoCompression Artifact Reduction
opencv,numpy,tensor格式转换
【软件工程之美 - 专栏笔记】31 | 软件测试要为产品质量负责吗?
【限时福利】21天学习挑战赛 - MySQL从入门到精通
IDEA2018.3.5取消双击Shift快捷键
Teach you how to build a permanently running personal server
类和对象——上
Babbitt | Metaverse Daily Must Read: The shuffling is coming, will the digital Tibetan industry usher in a new batch of leaders in the second half?Will there be new ways to play?...
对一次生产环境产生OOM的记录,结论:除非在自己完全有把握的情况下,否则不要偷懒查询无用字段
Knowledge of C language corners of byte alignment
ENS emoji domain name is on fire!Hype or opportunity?
微信公众号授权登录后报redirect_uri参数错误的问题
[Nuxt 3] (十四) Nuxt 生命周期
Image Restoration by Estimating Frequency Distribution of Local Patches
【信息安全技术】RSA算法的研究及不同优化策略的比较
Generate OOM records in a production environment. Conclusion: Don't be lazy to query useless fields unless you are completely sure.
nVisual网络可视化管理平台功能和价值点