An item with the same key has already been added

Hello.
When using the get cookies block in the puppeteer, I get the error
[Executing block Get Cookies] ArgumentException: An item with the same key has already been added. Key: gid

Снимок экрана 2022-03-22 165849

I understand that the reason in 2 cookies with the same name, but how to solve this problem?

This happens if 2 cookies in different sites have the same name. Please specify the domain you are interested in instead of leaving it blank, so that only the cookies for that specific domain will be retrieved.

maybe use cookiescontainer no ? with DotNet 6 we have more function

This would mean that cookies are not a dictionary variable anymore, which makes it harder to pass cookies around and do operations on them. CookieContainer has been around since long before .NET 6 but I decided not to use it to avoid further complications for the config makers. Using Dictionary<string, string> is way easier and it works for most use cases when targeting a single site.

It allows to easily port over cookies from one domain to the other as well without any need for the user to manually do that. This has been a problem before, and was one of the many reasons why I went with this years ago.

2 Likes

Hi @Ruri i have the same problem, instead of using blank domain im using the specity domain, i’m still getting the same error.

im still getting this error
An item with the same key has already been added

when i use domain i get 0 cookies