久久久久久久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国产 | 成人精品一区二区三区中文字幕 | 国产成人精品免高潮在线观看 | 爱爱视频在线观看 | 精品亚洲一区二区三区 | 中文欧美日韩 | 欧美福利网站 | 久久久www成人免费无遮挡大片 | 天天看天天爽 | 鲁视频| 亚洲综合久久久 | 欧美一区二区三区在线观看 | 精品福利在线 | 日韩电影一区二区三区 | 国产精品电影在线观看 | 伊人网站 | 亚洲成人av在线播放 | 久久精品欧美一区二区三区不卡 | 久久久久久国产 | 久久一区二区三区电影 | 日韩精品一区二区三区中文在线 | 亚洲性视频在线 | 亚洲网一区 | 一本色道精品久久一区二区三区 | 美女视频久久 | 成人午夜精品一区二区三区 | 国产精品影视在线观看 | 国产精品久久久久一区二区三区 | 国产成人福利在线观看 | 国产精品一区二区三区在线 | 狠狠综合久久av一区二区老牛 | 美女爽到呻吟久久久久 | 91精品久久久久久久久久入口 | 欧美国产中文 | 99久久婷婷国产综合精品电影 | 毛片在线视频 | 国产精品国产三级国产aⅴ中文 | 国产精品成人一区二区三区夜夜夜 | 九九免费在线视频 | 99免费在线视频 | 国产午夜精品一区二区三区四区 |