title: how to remove/update a cookie in cookie container c#?
body: <p>I open a website using webbrowser control and then save cookies in cookieContainer , and later use HTTPwebrequest to process forward browsing pages etc.</p>
  
  <p>The issue arises, when i make a search and it returns 100 pages,on the first page ,it saves a cookie named : ABC ,which i add to the cookiecontainer and move to the next page , on the second page again same Cookie named: ABC is given some value, but now i have two same cookies in cookiecontainer and when i move to the next page it does not work , as its taking the first cookie which messes everything.</p>
  
  <p>How to solve this?</p>
  
  <p>HttpWEBREQUEST FUNCTION:</p>
  
  <pre><code> public string getHtmlCookies(string url)
      {
          string responseData = "";
          try
          {
              HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
              request.Accept = "*/*";
              request.AllowAutoRedirect = true;
              request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)";
              request.Timeout = 30000;
              request.Method = "GET";
              request.CookieContainer = yummycookies;
  
              HttpWebResponse response = (HttpWebResponse)request.GetResponse();
              if (response.StatusCode == HttpStatusCode.OK)
              {
                  foreach (Cookie cookie in response.Cookies)
                  {
                      string name = string.Empty;
                      name = cookie.Name;
                      string value = cookie.Value;
                      string path = "/";
                      string domain = "www.example.com";
                      yummycookies.Add(new Cookie(name.Trim(), value.Trim(), path, domain));
  
                  }
  
  
                  Stream responseStream = response.GetResponseStream();
                  StreamReader myStreamReader = new StreamReader(responseStream);
                  responseData = myStreamReader.ReadToEnd();
              }
              response.Close();
  
  
          }
          catch (Exception e)
          {
              responseData = "An error occurred: " + e.Message;
          }
  
          return responseData;
  
      }
  </code></pre>