Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

browser.page.cookies does not return cookies only used by that page #368

Open
postmodern opened this issue Jul 5, 2023 · 4 comments
Open

Comments

@postmodern
Copy link
Contributor

I feel like browser.cookies should return all cookies, while browser.page.cookies should only return cookies for the page, based on the current page's path and domain.

@route
Copy link
Member

route commented Jul 6, 2023

@postmodern could you show an example where it's useful?

@postmodern
Copy link
Contributor Author

@route I want to dump out the cookies used by the current page to a file, so I can load the cookies into other tools or back into a new Ferrum::Browser instance. I noticed that both browser.cookies and browser.page.cookies returns cookies for the current website domain, and all previous websites that the browser instance has visited. I suppose I could add my own method which filters browser.cookies by comparing Cookie#domain against URI(browser.url).host.

@route
Copy link
Member

route commented Jul 14, 2023

Since browser.cookies is just a convenient alias to browser.page.cookies with default page, this behavior looks ok to me. Though I'm a bit surprised that Network.getAllCookies returns all cookies even for previously visited websites but thinking a bit more about it and this is also appears to be correct behavior from Chrome's perspective because context stays the same. Like you said you can just filter out unneeded cookies by domain.

@route route closed this as completed Jul 14, 2023
@postmodern
Copy link
Contributor Author

Maybe in ferrum 1.0.0 you could rename cookies to cookie_jar which would imply all cookies, and have a cookies method that only returned the cookies used by the current page.

@route route reopened this Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants