0

I'm trying to use Chromium DevTools protocol in CEF, more precisely the "Network.deleteCookies" method: https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-clearBrowserCookies

1.First I upload stackoverflow.com and I log in on it and close the site.

2.Then I upload again stackoverflow.com and I see that I am logged in automatically, that is, Chromium has sent authorization cookies.

3.Now I'm uploading again stackoverflow.com BUT now I want to delete cookies using DevTools protocol, for this before Chromium sends the first request to stackoverflow.com - I'm calling DevTools method "Network.getCookies".

I get all the cookie data that is stored in the cookie cache for stackoverflow.com:

{"cookies":[{"name":"_ym_isad","value":"2","domain":".stackoverflow.com","path":"/","expires":1656592856,"size":9,"httpOnly":false,"secure":true,"session":false,"sameSite":"None","priority":"Medium","sameParty":false,"sourceScheme":"Secure","sourcePort":443},{"name":"_ym_uid","value":"1656511499689981928","domain":".stackoverflow.com","path":"/","expires":1688056856,"size":26,"httpOnly":false,"secure":true,"session":false,"sameSite":"None","priority":"Medium","sameParty":false,"sourceScheme":"Secure","sourcePort":443},...

I won't copy the entire json message- it's just that it's big. But, I have filtered out all the cookie names:

_ym_isad
_ym_uid
acct
OptanonConsent
_gid
_ym_d
__gpi
__gads
_ga
prov

Next I call DevTools method "Network.deleteCookies" for each cookie name:

the resulting Json code of the "Network.deleteCookies" method call is as follows:

{"id":13,"method":"Network.deleteCookies","params":{"name":"_ym_isad","url":"https://www.stackoverflow.com"}}
{"id":14,"method":"Network.deleteCookies","params":{"name":"_ym_uid","url":"https://www.stackoverflow.com"}}
{"id":15,"method":"Network.deleteCookies","params":{"name":"acct","url":"https://www.ru.stackoverflow.com"}}
{"id":16,"method":"Network.deleteCookies","params":{"name":"OptanonConsent","url":"https://www.stackoverflow.com"}}
{"id":17,"method":"Network.deleteCookies","params":{"name":"_gid","url":"https://www.stackoverflow.com"}}
{"id":18,"method":"Network.deleteCookies","params":{"name":"_ym_d","url":"https://www.stackoverflow.com"}}
{"id":19,"method":"Network.deleteCookies","params":{"name":"__gpi","url":"https://www.stackoverflow.com"}}
{"id":20,"method":"Network.deleteCookies","params":{"name":"__gads","url":"https://www.stackoverflow.com"}}
{"id":21,"method":"Network.deleteCookies","params":{"name":"_ga","url":"https://www.stackoverflow.com"}}
{"id":22,"method":"Network.deleteCookies","params":{"name":"prov","url":"https://www.stackoverflow.com"}}

4.Next, a message comes from DevTools for each call to "Network.deleteCookies":

{"id":3,"result":{}}

That is, the method completed successfully without errors.

HOWEVER, the cookies have not been deleted, and CEF/Chromium sends these cookies to the server.

What's wrong? DevTools "Network.deleteCookies" method - doesn't work ?

Optimus1
  • 444
  • 2
  • 13
  • @273K, unfortunately, I also tried this, the result is the same. – Optimus1 Jun 30 '22 at 06:54
  • Remove `www.` and add `/` so it becomes `https://stackoverflow.com/` – wOxxOm Jun 30 '22 at 13:39
  • @wOxxOm, I have already tried all the formats, and the one that you suggested. The result is the same. DevTools returns a successful result, but does not delete cookies. – Optimus1 Jun 30 '22 at 17:11
  • Try specifying the reported values i.e. "domain":".stackoverflow.com","path":"/" – wOxxOm Jun 30 '22 at 17:14
  • @wOxxOm, Thanks, for stackoverflow - it worked. But for "domain":".youtube.com ","path":"/" - does not work :( – Optimus1 Jun 30 '22 at 20:03
  • Maybe youtube cookie is using a different domain/path? – wOxxOm Jul 01 '22 at 05:02
  • @wOxxOm, How can youtube use a domain other than youtube ? :) The answer, of course not: the youtube domain is youtube.com – Optimus1 Jul 01 '22 at 05:57
  • It can use `www.youtube.com` or `.youtube.com` or `youtube.com`. – wOxxOm Jul 01 '22 at 12:03
  • @wOxxOm, I've tried all these names, but they don't work. Moreover, the "Network.getCookies" - gives me the Domain name and nothing works. In general, we can say that "Network.deleteCookies" for Chrome DevTools protocol does not work. – Optimus1 Jul 01 '22 at 12:16
  • 1
    If you use *exactly the same* `domain` and `path` as shown by getCookies, it's a bug that you can report on https://crbug.com. – wOxxOm Jul 01 '22 at 12:17
  • @wOxxOm, everything turned out to be simpler, not only YouTube cookies are used for authorization on YouTube, but also Google cookies. – Optimus1 Jul 13 '22 at 10:44

0 Answers0