Javascript Puppeteer Invalid Cookie Fields

Viewed 24

I'm trying to access a website that only allows me to go through if I change the value of some cookies, however whenever I try to change the value of the __Secure-3PSIDCC cookie it tells me that it is an Invalid cookie field

DevTools listening on ws://127.0.0.1:33837/devtools/browser/e3f433a2-8a43-481b-9a2f-b6aa4a923228
MESA-INTEL: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0

libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[27423:27516:0915/232908.850008:ERROR:nss_util.cc(349)] After loading Root Certs, loaded==false: NSS error code: -8018
/home/bonk/Kisa/testing/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:298
                error: new Errors_js_1.ProtocolError(),
                       ^

ProtocolError: Protocol error (Network.setCookies): Invalid cookie fields
    at /home/bonk/Kisa/testing/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:298:24
    at new Promise (<anonymous>)
    at CDPSession.send (/home/bonk/Kisa/testing/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:294:16)
    at Page.setCookie (/home/bonk/Kisa/testing/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:869:67)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async f (/home/bonk/Kisa/testing/test.js:75:5) {
  originalMessage: 'Invalid cookie fields'

here is my code

const f = (async() => {
    const browser = await puppeteer.launch({      
      dumpio: true,
      headless: false
    });
    const page = await browser.newPage();
    page.setUserAgent(
  "Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0"
);
    const cookies = [
    {
      'name': '__Secure-3PSIDCC',
      'value': 'hello', domain: '.google.com'
    }
    
    
    ];
    await page.setCookie(...cookies);
    await page.goto("https://google.com");
    
    //await page._client.send("Page.setDownloadBehavior", {
    //  behavior: "allow",
    //  downloadPath: "./anime/" + titlee
    //})
    await setTimeout(async() =>{
        const link = await page.evaluate(() => document.querySelector('*').outerHTML);
        await page.mouse.click(782, 354);
        await setTimeout(async() =>{
        await page.bringToFront();
        await page.mouse.click(782, 354);
      }, 10);
    }, 10000);
});
f();

changing the value of __Secure-3PSIDCC cookie on firefox works however it throws me the error above when I try and change the cookie value in chromium

0 Answers
Related