-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CookieContainer doesn't replace Cookie with same name #84820
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsDescriptionCookieContainer doesn't replace cookie which added using Reproduction Steps
Expected behaviorNew cookie received from web server must replace existing cookie with same name Actual behaviorNew cookie doesn't replace old cookie and we have two cookies with same name Regression?No response Known WorkaroundsNo response ConfigurationWin 10 .Net 6.0.16 7.0.5 .Net Framework 4.7 4.8 4.8.1 Other information
request cookies: resonce cookies: CookieContainer content:
|
For some reason, the manually created cookie gets the I'd say this belongs to the batch of cookie problems in #40328. We also did some targeted fix for leading dot in #39781. |
Looking more into the history, seems like #64038 didn't catch all possibilities. We might also use: runtime/src/libraries/Common/src/System/Net/CookieComparer.cs Lines 25 to 30 in d0a287a
As equality comparer for the hashtable:
|
A minimal repro to trigger this issue would be: Uri uri = new Uri("https://arduino.ua");
CookieContainer container = new();
Cookie a = new()
{
Domain= "arduino.ua",
Name = "FBeID",
Value = "0"
};
container.Add(uri, a);
container.SetCookies(uri, "FBeID=42");
Assert.Equal(1, container.Count);
The manually created cookie has an explicitly set domain and cookie.Domain = "arduino.ua"; According to RFC 6265 we should remove leading dots not add them, however I would be afraid to apply any naïve changes to the code without reviewing the bigger picture and the behavior of various browsers like for other cases described in #40328. Unfortunately, people may depend on the current behavior. Moving to Future for now. |
Description
CookieContainer doesn't replace cookie which added using
CookieContainer.Add(Uri uri, Cookie cookie)
Reproduction Steps
Expected behavior
New cookie received from web server must replace existing cookie with same name
Actual behavior
New cookie doesn't replace old cookie and we have two cookies with same name
Regression?
No response
Known Workarounds
No response
Configuration
Win 10 .Net 6.0.16 7.0.5 .Net Framework 4.7 4.8 4.8.1
Other information
request cookies:
Cookie: FBeID=nnnnn
resonce cookies:
Set-Cookie: PHPSESSID=eljpt8ef572ulpqn6bkv6io93h; expires=Thu, 18-Jan-2024 02:33:24 GMT; Max-Age=24105600; path=/
Set-Cookie: FBeID=1423878233
CookieContainer content:
PHPSESSID=eljpt8ef572ulpqn6bkv6io93h
FBeID=1423878233
FBeID=nnnnn
The text was updated successfully, but these errors were encountered: