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

Cookie value in browser console differs from the one obtained in code. #190

Open
aryab42 opened this issue Jul 26, 2023 · 1 comment
Open

Comments

@aryab42
Copy link

aryab42 commented Jul 26, 2023

cookies = list(browser_cookie3.load(domain_name = ".google.com"))
main_cookie = [cookie for cookie in cookies if cookie.name == "__Secure-1PSID"][0]

This is the code and the cookie value obtained in browser console differs entirely from the one obtained via code

@rafiibrahim8
Copy link
Collaborator

Hi,
This may happen for two reasons:

1. The exact cookie exists in multiple browsers:

I see you are using the load function. The function loads cookies from all available browsers in your system into a single CookieJar. Thus if the exact cookie say __Secure-1PSID exists on two browsers say chrome and firefox another will replace one. I suggest using the function for the browser you are trying to load from to avoid it. For example for Chrome use:

cookies = list(browser_cookie3.chrome(domain_name = ".google.com"))

2. To cookie is recently updated in the browser:

Another scenario (although less likely) is that the cookie is very new and hasn't been updated on the disk yet. As browser-cookie3 reads cookies from disk. It is unable to produce the latest cookie.

Hope this helps.

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