原文转自https://www.cnblogs.com/gigi2653/p/13426051.html
以及https://blog.csdn.net/sinat_36521655/article/details/104844667
开发环境下,修改了本机host映射,请求的接口地址跟本机开发环境的域名不同源(请求跨域),在使用新版Chrome浏览器(80版本号)后,在登录页面输入验证码时,总是提示验证码过期,但是换用firefox却能正常登录,是因为验证码接口和登录接口的session不一致(跨域问题),新版谷歌浏览器加入了 SameSite。
解决方法:
- 在chrome中打开链接: chrome://flags/,搜索samesite
- 将 SameSite by default cookies,Enable removing SameSite=None cookies,Schemeful Same-Site 上述三个选项禁用(设为disable)后重启chrome,问题解决。
在服务器端的 header 中设置samesite,即上述的 response.setHeader(name: “Set-Cookie”, value: “_u=xxxx; Path=/Login; SameSite=None; Secure=true”)后,使用https传输cookie