1

When I use HttpWebRequest in .NET, its CookieContainer object doesn't contain cookies that have a , (comma) in them - for example, if a cookie looks like this:

guest_id=v1%3A142425134212809164; Domain=.twitter.com; Path=/; Expires=Fri, 17-Feb-2017 09:22:22 UTC

The request's CookieContainer won't contain this cookie because it has a comma inside it (in the Expires parameter). On the other hand, when cookies do not contain commas in them, the CookieContainer object gets them correctly.

Is there a workaround for this issue?

BlueRay101
  • 1,447
  • 2
  • 18
  • 29
  • 1
    I too have noticed this 'problem' and never bothered to find out why this happens. It's easy enough to fix this by changing the date format. The quick solution would be to remove the date name part (Fri) and send `guest_id=v1%3A142425134212809164; Domain=.twitter.com; Path=/; Expires=17-Feb-2017 09:22:22 UTC` instead. – Joe Uhren Feb 18 '15 at 18:40
  • @JoeyJoeJoeJrShabadoo , thank you very much! Can you please provide some code on how to correctly receive the cookie with the Expires parameter into the CookieContainer? I can't just send this same data again and again because the `guest_id` cookie's value is randomly generated in every visit to Twitter. – BlueRay101 Feb 18 '15 at 22:10
  • Nevermind, I have successfully added the cookie without the Expires parameter to the global CookieContainer object as you have suggested (all requests use the same CookieContainer). This is how I did it: `AllCookies.Add(new Cookie("guest_id", "v1%3A142425134212809164", "/", ".twitter.com"));`. The requests now send the cookie that I have added, and they do it just fine - the program works flawlessly! Thanks again for your help :) – BlueRay101 Feb 18 '15 at 22:36

1 Answers1

0

Unfortunately, .Net CookieParser internal class, does not support UTC in date format, must be GMT.

ZeRicco
  • 23
  • 6