Skip to content

Page.GetCookiesAsync does not return all the cookies #1881

@heinsenberg82

Description

@heinsenberg82

The method Page.GetCookiesAsync() doesn't return all the cookies showed in the Chrome Dev Tools. After googling this issue, i found a nice explanation on Stack Overflow (https://stackoverflow.com/questions/49389775/puppeteers-page-cookies-not-retrieving-all-cookies-shown-in-the-chrome-dev-to/59604510). So basically the cookie i want is probably an httpOnly cookie, wich is not retrieved by the "Network.getCookies" command performed by the Page.GetCookiesAsync() method.

My humble suggestion would be adding an method called Page.GetAllCookiesAsync(), with this implementation:

public async Task<CookieParam[]> GetAllCookiesAsync(params string[] urls) => (await Client.SendAsync<NetworkGetCookiesResponse>("Network.getAllCookies", new NetworkGetCookiesRequest { Urls = urls.Length > 0 ? urls : new string[] { Url } }).ConfigureAwait(false)).Cookies;

In other words, just a clone of the already existing Page.GetCookiesAsync() method, but with the "Network.getAllCookies" call instead of the "Network.getCookies".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Upstream Change neededWe need to wait for changes in Chromium or Puppeteer (Node.JS)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions