In my Winforms project, I can get a cookie of a site opened in IE by the following method :
InternetGetCookie("mysite.com", "mycookie", "something" , "something" )
As a new requirement coming, the site must be opened in Chrome. That means the method above doesn't work anymore.
After some research, I found out a solution to use Sqlite
to read the cookies
file stored in "Users\xx\AppData\Google\Chrome\User Data\Default\cookies"
, it works as expected. I can fetch the cookie by giving the name and URL.
BUT PROBLEM: The cookies file is not up-to-date and is updated 1-2 minutes laters. That means the cookies of the request shown in Chrome DevTool is not the same as in the cookies
file.
Is there any way to fetch the cookie in Chrome from C# Winforms project similar to InternetGetCookie
?
Updated August 4, 2022. Google has announced that it will stop the use of third-party cookies in Chrome by the end of 2024, joining a growing list of browsers ditching the notorious tracking technology.
For Google Chrome the default location for cookies is %LocalAppData%\Google\Chrome\User Data\Default\cookies. For Microsoft Edge Chromium this is %LocalAppData%\Microsoft\Edge\User Data\Default\cookies.
Why Did Google Delay Third-Party Cookie Deprecation on Chrome? Google is primarily pushing the timeline to provide a longer testing periods for the Privacy Sandbox and its related solutions that support cookieless marketing.
Hmm, there doesn't seem to be a chrome flag to flush this quicker so probably not going to be an easy option... You could maybe:
Grab it from memory (may be possible if you can search for the value somehow)
Write a Chrome extension which dumps it immediately
Use a headless browser instance to visit the site and send the cookie back instead
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With