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".
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 anhttpOnlycookie, wich is not retrieved by the"Network.getCookies"command performed by thePage.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".