Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome cookie not up-to-date

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?

like image 660
Antoine V Avatar asked Apr 01 '19 15:04

Antoine V


People also ask

Is Chrome getting rid of cookies?

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.

Where are the Chrome cookies stored?

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 are Google delaying the deprecation of 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.


1 Answers

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

like image 92
Milney Avatar answered Oct 30 '22 20:10

Milney