自上次更新以来,我的Cookie出现错误,与SameSite属性相关。
Cookies来自第三方开发人员(Fontawesome,jQuery,Google Analytics,Google reCaptcha,Google Fonts等)。
Chrome控制台中的错误是这样的。
A cookie associated with a cross-site resource at <URL> was set without the `SameSite` attribute. A future release of Chrome will only deliver 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 <URL> and <URL>.
(index):1 A cookie associated with a cross-site resource at http://jquery.com/ was set without the `SameSite` attribute. A future release of Chrome will …Run Code Online (Sandbox Code Playgroud) 我创建了一个chrome扩展程序,并从popup.js中调用了读取cookie的PHP脚本(使用Xhttprequest)。像这样:
$cookie_name = "mycookie";
if(isset($_COOKIE[$cookie_name]))
{
echo $_COOKIE[$cookie_name];
}
else{
echo "nocookie";
}
Run Code Online (Sandbox Code Playgroud)
但是我收到扩展错误的警告。
与(此处是我的域)的跨站点资源关联的cookie设置为未设置
SameSite属性。如果将来的Chrome浏览器版本将cookie设置为SameSite=None和,则仅会提供带有跨站点请求的cookieSecure。您可以在“应用程序”>“存储”>“ Cookies”下的开发人员工具中查看Cookie,并在https://www.chromestatus.com/feature/5088147346030592和https://www.chromestatus.com/feature/5633521622188032上查看更多详细信息。
我试图创建这样的cookie,但没有帮助。
setcookie($cookie_name,$cookie_value, time() + 3600*24, "/;samesite=None ","mydomain.com", 1);
Run Code Online (Sandbox Code Playgroud)
遵循此问题的指示。