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_cookie3 using outdated cookies? #183

Open
Andrew3019 opened this issue Jul 2, 2023 · 1 comment
Open

browser_cookie3 using outdated cookies? #183

Andrew3019 opened this issue Jul 2, 2023 · 1 comment

Comments

@Andrew3019
Copy link

Andrew3019 commented Jul 2, 2023

Hello, I am having a problem with browser cookie 3 not returning the most recent cookie values. I'm trying to access to access two different cookies, one of them is correct, but the other one does not have the same value as when I check in chrome dev tools. I have deleted/changed/reloaded the cookie in chrome and it still does not change in my python script. The only thing different about these two cookies is that the one that isn't updating has an expiration date (in a year), while the correct one has no expiration date.

This is what I am using to get the cookie values:

print([i for i in list(browser_cookie3.chrome(domain_name='steamcommunity.com')) if i.name == "steamLoginSecure"][0].value)
print([i for i in list(browser_cookie3.chrome(domain_name='steamcommunity.com')) if i.name == "sessionid"][0].value)

The first one is not updating. I'm not sure about the second one, but the first one is not the same as the value I see in chrome dev tools and I have tried everything to get it to refresh.

@mahlzahn
Copy link

mahlzahn commented Sep 12, 2023

Maybe you have different places where the cookies are stored and thus it finds the wrong ones. Depending on your system the cookie file is automatically chosen by the first file it finds, see for the corresponding code lines here:

def __init__(self, cookie_file=None, domain_name="", key_file=None):
args = {
'linux_cookies': _genarate_nix_paths_chromium(
[
'~/.config/google-chrome{channel}/Default/Cookies',
'~/.config/google-chrome{channel}/Profile */Cookies',
'~/.var/app/com.google.Chrome/config/google-chrome{channel}/Default/Cookies',
'~/.var/app/com.google.Chrome/config/google-chrome{channel}/Profile */Cookies'
],
channel=['', '-beta', '-unstable']
),
'windows_cookies': _genarate_win_paths_chromium(
[
'Google\\Chrome{channel}\\User Data\\Default\\Cookies',
'Google\\Chrome{channel}\\User Data\\Default\\Network\\Cookies',
'Google\\Chrome{channel}\\User Data\\Profile *\\Cookies',
'Google\\Chrome{channel}\\User Data\\Profile *\\Network\\Cookies'
],
channel=['', ' Beta', ' Dev']
),
'osx_cookies': _genarate_nix_paths_chromium(
[
'~/Library/Application Support/Google/Chrome{channel}/Default/Cookies',
'~/Library/Application Support/Google/Chrome{channel}/Profile */Cookies'
],
channel=['', ' Beta', ' Dev']
),

You can also give directly the path of the correct cookie file to the function call:

browser_cookie3.chrome(cookie_file='path/to/correct/cookie_file', ...)

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