question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to get all cookies?

See original GitHub issue

Hi yujiosaka,

I’m trying to retrieve all the cookies on a page (1st and third party cookies).

The default result.cookies only contains 1st party cookies:

onSuccess: (result => {
    console.log(result.cookies);
}),

There is a way with Puppeteer to get all cookies, including third party with the await page._client.send('Network.getAllCookies')); method.

So I’m trying to use that with the crawler, however the onSuccess method only returns result which doesn’t contain a reference to Puppeteer’s page object.

Do you know where I can call the async page._client.send('Network.getAllCookies')); method so I can retrieve all cookies (1st/third) on every crawled page?

Many thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
Zeikkocommented, Jul 5, 2018

With headless-chrome-crawlerversion 1.8.0 you can use this customCrawl function to get all cookies:

async function customCrawl(page, crawl) {
  const result = await crawl();
  const cookies = await page._client.send('Network.getAllCookies');
  result.cookies = cookies.cookies;
  return result;
}
1reaction
BubuAnabelascommented, May 23, 2018

@pandacoder

Actually page is exposed through the newpage event and from there you could access browser or target. But as it’s currently exposed it makes it difficult to get/set cookies correctly. I agree that headless-chrome-crawler should be well focused but it needs to be extendable enough to be able to do these kind of things.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I need to get all the cookies from the browser - Stack Overflow
To retrieve all cookies for the current document open in the browser, you again use the document.cookie property.
Read more >
How to list all the cookies of the current page using JavaScript
Access the cookies using document.cookie. · Use the .split() method to split them on “;” to get an array of cookies. · Traverse...
Read more >
cookies.getAll() - Mozilla - MDN Web Docs
The getAll() method of the cookies API retrieves all cookies from a single cookie store that match the given information.
Read more >
Clear, enable, and manage cookies in Chrome - Android
Clear all cookies ; To the right of the address bar, tap More More and then Settings. ; Tap Privacy and security and...
Read more >
5 Ways to View Cookies - wikiHow
1. Open Google Chrome. It's a green, red, blue, and yellow sphere icon. 2. Click ⋮. This icon is in the top-right corner...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found