Apify and Crawlee Official Forum

Updated 3 months ago

setCookie and session.getCookies don't work together

I'm trying to run this code in my default handler:
Plain Text
if (request.loadedUrl === 'url-from-where-i-get-cookies'){
        goodCokies = session.getCookies('url-from-where-i-get-cookies')
        await crawler.addRequests(['url-where-i-need-cookies'])
        return
    }
    await page.setCookie(goodCokies)


Error:
Plain Text
Reclaiming failed request back to the list or queue. Protocol error (Network.deleteCookies): Invalid parameters Failed to deserialize params.name - BINDINGS: mandatory field missing at position 2081
A
1 comment
1) Which crawler are you using? Puppeteer has a different signature for setting cookies: await page.setCookie(...goodCookies)
2) Are you sure that session actually has the cookie assigned to it? Cookies are saved to session after requestHandler finishes successfully.
Add a reply
Sign up and join the conversation on Discord