244

Since the last update, I'm having an error with cookies, related with SameSite attribute.

The cookies are from third party developers (Fontawesome, jQuery, Google Analytics, Google reCaptcha, Google Fonts, etc.)

The errors in the Chrome console are like this.

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 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.
(index):1 A cookie associated with a cross-site resource at http://fontawesome.com/ 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.
(index):1 A cookie associated with a cross-site resource at http://google.com/ 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.
(index):1 A cookie associated with a cross-site resource at https://google.com/ 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.
(index):1 A cookie associated with a cross-site resource at https://www.google.com/ 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.
(index):1 A cookie associated with a cross-site resource at http://www.google.com/ 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.
(index):1 A cookie associated with a cross-site resource at http://gstatic.com/ 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.

Is there anything I need to do in my local machine or server or is just some feature they should implement in future releases of their libraries?

8
  • 14
    nothing to do with your code. its something their web servers will have to support. Oct 7, 2019 at 13:39
  • 3
    You can use the libraries without any problem. It is just a warning the console will throw until they implement that in their servers as @DanielA.White said before.
    – peiblox
    Oct 9, 2019 at 7:14
  • 13
    And what exactly happens if the 3rd party does not fix their cookies by the date that A future release of Chrome will only deliver ... - will my site break? Looks like that future date is 02/04/2020 - not too far away.
    – JK.
    Nov 26, 2019 at 21:24
  • 2
    As mentioned by @DanielA.White, this needs to be fixed at the third party code, see this answer for more context. Jan 16, 2020 at 21:30
  • 1
    Strange though that Google Chrome is referring to functionality that another Google service -- Google Charts in my case, retrieved from gstatic.com in the OP -- needs to change in order to comply. You'd guess that the team for Google Chrome communicates with the team for Google Charts. :-) Jul 28, 2020 at 13:17

6 Answers 6

183

This console warning is not an error or an actual problem — Chrome is just spreading the word about this new standard to increase developer adoption.

It has nothing to do with your code. It is something their web servers will have to support.

Release date for a fix is February 4, 2020 per: https://www.chromium.org/updates/same-site

February, 2020: Enforcement rollout for Chrome 80 Stable: The SameSite-by-default and SameSite=None-requires-Secure behaviors will begin rolling out to Chrome 80 Stable for an initial limited population starting the week of February 17, 2020, excluding the US President’s Day holiday on Monday. We will be closely monitoring and evaluating ecosystem impact from this initial limited phase through gradually increasing rollouts.

For the full Chrome release schedule, see here.

I solved same problem by adding in response header

response.setHeader("Set-Cookie", "HttpOnly;Secure;SameSite=Strict");

SameSite prevents the browser from sending the cookie along with cross-site requests. The main goal is mitigating the risk of cross-origin information leakage. It also provides some protection against cross-site request forgery attacks. Possible values for the flag are Lax or Strict.

SameSite cookies explained here

Please refer this before applying any option.

15
  • 44
    Have you done any research on how this could be handled when pulling in 3rd party scripts that set cookies (like Google Analytics and Google Tag Manager)?
    – BRass
    Oct 14, 2019 at 19:47
  • 2
    If perchance you're using .NET, appending the web.config or adding URL ReWrite rules in IIS would address this issue. Credit goes to the solution at stackoverflow.com/questions/38954821/…
    – BDarley
    Oct 25, 2019 at 14:10
  • 3
    Is there a solution that does not involve JavaScript?
    – posfan12
    Oct 27, 2019 at 11:50
  • 43
    I must say that a friendly warning really triggers the OCD of many developers like me. My frustration at the dirty console raises considerably when I see YouTube, a Google property, an offender generating console errors in Google Chrome.. This is the way, I have spoken.
    – Marc
    Jan 6, 2020 at 5:22
  • 3
    Any ideas why a simple request of an image would trigger this error? Even when the image request does not involve creating/reading a cookie, and the image domain URL does not match the cookie URL reported by the Chrome console warning message?
    – andreszs
    Feb 20, 2020 at 14:14
44

Update - June 2021

The chrome flag for #same-site-by-default is removed from the Chrome experiments panel as Chrome 91.

The flag is still available via the launch options until Chrome 94.

For macos the terminal command to launch with the flag is:

// Chrome
open -n -a Google\ Chrome --args --disable-features=SameSiteByDefaultCookies

// Chrome Canary
open -n -a Google\ Chrome\ Canary --args --disable-features=SameSiteByDefaultCookies

More info:

Mar 18, 2021: The flags #same-site-by-default-cookies and #cookies-without-same-site-must-be-secure have been removed from chrome://flags as of Chrome 91, as the behavior is now enabled by default. In Chrome 94, the command-line flag --disable-features=SameSiteByDefaultCookies,CookiesWithoutSameSiteMustBeSecure will be removed. Source: Chromium SameSite Updates page.


Original Answer - March 2020

If you are testing on localhost and you have no control of the response headers, you can disable it with a chrome flag.

Visit the url and disable it: chrome://flags/#same-site-by-default-cookies SameSite by default cookies screenshot

I need to disable it because Chrome Canary just started enforcing this rule as of approximately V 82.0.4078.2 and now it's not setting these cookies.

Note: I only turn this flag on in Chrome Canary that I use for development. It's best not to turn the flag on for everyday Chrome browsing for the same reasons that google is introducing it.

1
  • 5
    Disabling this flag and relaunching canary did not work for me, so I just added -SameSite to the main "Filter" box, which I also used to remove this annoying sourcemap issue => superuser.com/questions/1523427/…
    – Andrew
    Mar 28, 2020 at 4:53
14

Fixed by adding crossorigin to the script tag.

From: https://code.jquery.com/

<script
  src="https://code.jquery.com/jquery-3.4.1.min.js"
  integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
  crossorigin="anonymous"></script>

The integrity and crossorigin attributes are used for Subresource Integrity (SRI) checking. This allows browsers to ensure that resources hosted on third-party servers have not been tampered with. Use of SRI is recommended as a best-practice, whenever libraries are loaded from a third-party source. Read more at srihash.org

5
  • srihash.org says Unfortunately we do not know this domain.
    – Vlad
    Apr 22, 2020 at 9:09
  • Where do i find the script tag? Is it in the web.config?
    – CarlD
    Apr 28, 2020 at 12:51
  • 1
    @CarlD from the error message find which script is causing the error then view the html source of the webpage Apr 30, 2020 at 11:10
  • 2
    @JohnMagnolia I just did and nothing happened.
    – CarlD
    Apr 30, 2020 at 19:18
  • Will it work if I simply add this to the head tag of my website? Jul 15, 2020 at 22:21
9

To elaborate on Rahul Mahadik's answer, this works for MVC5 C#.NET:

AllowSameSiteAttribute.cs

public class AllowSameSiteAttribute : ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        var response = filterContext.RequestContext.HttpContext.Response;

        if(response != null)
        {
            response.AddHeader("Set-Cookie", "HttpOnly;Secure;SameSite=Strict");
            //Add more headers...
        }

        base.OnActionExecuting(filterContext);
    }
}

HomeController.cs

    [AllowSameSite] //For the whole controller
    public class UserController : Controller
    {
    }

or

    public class UserController : Controller
    {
        [AllowSameSite] //For the method
        public ActionResult Index()
        {
            return View();
        }
    }
0
1

I had to disable this in chrome://flags

enter image description here

1
  • 5
    Don't do that. It's just a hack and not a solution. Plus you are playing with experimental features of chrome
    – Andrius
    Jul 2, 2020 at 6:19
1

When it comes to Google Analytics I found raik's answer at Secure Google tracking cookies very useful. It set secure and samesite to a value.

ga('create', 'UA-XXXXX-Y', {
    cookieFlags: 'max-age=7200;secure;samesite=none'
});

Also more info in this blog post

Not the answer you're looking for? Browse other questions tagged or ask your own question.