Chrome Extention: Unchecked runtime.lastError: Failed to parse or set cookie named "ASP.NET_SessionId"

Viewed 1572

I have developed a Chrome extention that modifies web pages for an ASP.net system used at my workplace.

Due to the new Cookie restrictions introduced in recent versions of Chrome, I have to remove the SameSite lax cookie and replace it with a SameSite none, secure cookie.

The organisation has recently updated Chrome from 75 to 80. Now it works for some people and is broken for others.

When attempting to use Chrome.cookies api, the error is Unchecked runtime.lastError: Failed to parse or set cookie named "ASP.NET_SessionId".

Everybody appears to be running the same version of Chrome, and the cookie key is always the same.

See below for code. I have replaced the urls for this example.

function sameSiteCookieMaker() {
    chrome.cookies.get({
        "url": "https://example.example.example.com.au",
        "name": "ASP.NET_SessionId"
    }, function(cookie) {
        state = cookie.value
        chrome.cookies.remove({
            "url": "https://example.example.example.com.au",
            "name": "ASP.NET_SessionId"
        }, function(cookie2) {
            chrome.cookies.set({
                "url": "https://example.example.example.com.au",
                "domain": "example.example.example.com.au",
                "httpOnly": true,
                "name": "ASP.NET_SessionId",
                "path": "/",
                "sameSite": "no_restriction",
                "secure": true,
                "storeId": "0",
                "value": state
            })
        })
    })
}
2 Answers

I got the same error. I solved it by following those rules:

  1. url should contain the value of domain. You are not allowed to use a different domain name for url.
  2. Chrome rejects any url with a leading dot, like https://.example.com/.
  3. url should match with secure. That means, whenever secure is true, url should start with https.

i got the same error, and after a little research i found out my cookie size exceeded the size limit.

Related