Antoine V
Antoine V

Reputation: 7204

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?

Upvotes: 6

Views: 297

Answers (1)

Milney
Milney

Reputation: 6427

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

Upvotes: 3

Related Questions