How to set cookies?

Hi,

So, we have deleteAllCookies. How do we set certain cookies?

The following didn’t work, no cookies are actually created despite not giving an error:

{
  "Name": "SetCookie",
  "CreationDate": "2021-3-9",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://github.com/",
      "Value": ""
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "document.cookie = \"username=John Doe\";",
      "Value": ""
    }
  ]
}

I’m not using executeScript because the website may not allow it, otherwise it works as intended. The example above is one of such websites.

Thanks!

Edit: Also, existing cookies may have an httpOnly flag, preventing them from being modified through Javascript

Great to hear that executeScript | document.cookie = \"username=John Doe\";" usually works.

But executeScript_Sandbox blocks all website access of the Javascript to avoid content security errors. So no surprise that it does not work as workaround for Github.

Can you maybe manually copy the cookie text file to the browser cache? Does this extension work with Github?

Hi,

EditThisCookie can indeed manipulate cookies on GitHub, so it’s possible to manipulate cookies through an extension.

Luckily, the website I’m currently dealing with it has no JS restriction other than an httpOnly flag that prevents cookies from being manipulated. I can deleteAllCookies and then recreate them.

However, for the future it might be wise to look at implementing cookie-related commands (particularly get/set) :slight_smile:

Thanks for the info. I am moving this thread to “Feature Suggestions” :wink: