chrome iframe cookies设置失败

前言

新版Chrome增加了一个功能 SameSite,可以禁止iframe设置cookies。

如果我们在iframe中需要登录验证,那就比较麻烦。可以通过禁用这个功能解决。

例子

浏览器控制台提示:

A cookie associated with a cross-site resource at http://58.211.78.91/ was set without the `SameSite` attribute. It has been blocked, as Chrome now only delivers cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/... and https://www.chromestatus.com/...

如果浏览器中提示以上内容,而且iframe中的请求中,出现以下情况:

基本可以确定是_SameSite的问题。_

解决

Chrome访问 chrome://flags/ ,搜索_SameSite,找到SameSite by default cookies,这是为Disabled,即可:_

作用是,禁止浏览器的SameSite功能生效。

你可能感兴趣的:(cookies,chrome,iframe跨域)