久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何修復“將 SameSite cookie 設置為無"警告?

How to fix quot;set SameSite cookie to nonequot; warning?(如何修復“將 SameSite cookie 設置為無警告?)
本文介紹了如何修復“將 SameSite cookie 設置為無"警告?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我創建了一個 chrome 擴展,并從 popup.js 調用讀取 cookie 的 PHP 腳本(使用 Xhttprequest).像這樣:

I created a chrome extension and from popup.js I called PHP script (Using Xhttprequest) that reads the cookie. Like this:

$cookie_name = "mycookie";

if(isset($_COOKIE[$cookie_name]))
{
    echo $_COOKIE[$cookie_name];
}
else{
    echo "nocookie";
}

但是我在擴展中的錯誤時收到此警告.

But I'm getting this warning at errors in extensions.

與 (Here is my domain) 的跨站點資源關聯的 cookie 設置為沒有 SameSite 屬性.如果使用 SameSite=NoneSecure 進行設置,Chrome 的未來版本將僅提供具有跨站點請求的 cookie.您可以在應用程序>存儲>Cookies 下的開發人員工具中查看 cookie,并在 https://www.chromestatus 上查看更多詳細信息.com/feature/5088147346030592 和 https://www.chromestatus.com/feature/5633521622188032.

A cookie associated with a cross-site resource at (Here is my domain) 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 https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.

我嘗試創建這樣的 cookie,但沒有幫助.

I tried to create a cookie like this but it didn't help.

setcookie($cookie_name,$cookie_value, time() + 3600*24, "/;samesite=None ","mydomain.com", 1);

按照這個問題中的說明進行操作.

Following instructions from this question.

推薦答案

我也在反復試驗"中為此,但是來自 Google Chrome Labs 的 Github 的這個答案對我有所幫助.我將它定義到我的主文件中并且它工作正常 - 很好,僅適用于一個第三方域.仍在進行測試,但我很想用更好的解決方案更新這個答案:)

I'm also in a "trial and error" for that, but this answer from Google Chrome Labs' Github helped me a little. I defined it into my main file and it worked - well, for only one third-party domain. Still making tests, but I'm eager to update this answer with a better solution :)

我現在使用的是 PHP 7.4,此語法運行良好(2020 年 9 月):

I'm using PHP 7.4 now, and this syntax is working good (Sept 2020):

$cookie_options = array(
  'expires' => time() + 60*60*24*30,
  'path' => '/',
  'domain' => '.domain.com', // leading dot for compatibility or use subdomain
  'secure' => true, // or false
  'httponly' => false, // or false
  'samesite' => 'None' // None || Lax || Strict
);

setcookie('cors-cookie', 'my-site-cookie', $cookie_options);


如果您有 PHP 7.2 或更低版本(正如羅伯特在下面回答的那樣):


If you have PHP 7.2 or lower (as Robert's answered below):

setcookie('key', 'value', time()+(7*24*3600), "/; SameSite=None; Secure");

如果您的主機已經更新到 PHP 7.3,您可以使用(感謝 Mahn 的評論):

If your host is already updated to PHP 7.3, you can use (thanks to Mahn's comment):

setcookie('cookieName', 'cookieValue', [
  'expires' => time()+(7*24*3600,
  'path' => '/',
  'domain' => 'domain.com',
  'samesite' => 'None',
  'secure' => true,
  'httponly' => true
]);

您可以嘗試檢查 cookie 的另一件事是啟用下面的標志,用他們自己的話來說,將為可能受此更改影響的每個 cookie 添加控制臺警告消息":

Another thing you can try to check the cookies, is to enable the flag below, which—in their own words—"will add console warning messages for every single cookie potentially affected by this change":

chrome://flags/#cookie-deprecation-messages

查看完整代碼:https://github.com/GoogleChromeLabs/samesite-examples/blob/master/php.md,他們也有 same-site-cookies 的代碼.

See the whole code at: https://github.com/GoogleChromeLabs/samesite-examples/blob/master/php.md, they have the code for same-site-cookies too.

這篇關于如何修復“將 SameSite cookie 設置為無"警告?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 亚洲人成在线播放 | 成人精品一区二区三区中文字幕 | 97在线观视频免费观看 | 99re在线免费视频 | 亚洲精品 在线播放 | 成人欧美一区二区三区黑人孕妇 | 欧美视频在线播放 | 99久久精品国产一区二区三区 | 人人鲁人人莫人人爱精品 | 亚洲欧美日韩精品久久亚洲区 | 午夜天堂精品久久久久 | 台湾佬成人网 | 天堂中文资源在线 | 午夜天堂 | 久久精品成人一区 | 99精品一区二区三区 | 日韩在线视频免费观看 | 波多野结衣一二三区 | 超碰97在线免费 | 婷婷在线免费 | 免费一区二区 | 欧美一区二区三区四区在线 | 成人福利电影 | 久久成人一区 | 久久夜色精品国产 | 自拍偷拍3p| 欧美一二三区 | 日本精品久久 | 欧美日韩一区二区三区四区 | 久久精品久久久久久 | 一区二区三区免费观看 | 日韩在线观看网站 | 欧美日高清 | www.色五月.com | av免费看在线 | 不卡欧美 | 精品一区二区三区在线观看国产 | 一级黄色日本片 | 在线资源视频 | 久久亚洲国产精品 | 国产自产21区 |