how to change the value or add a new cookie to an existing cookie? For example, I use a simple code as below :
Uri site = new Uri(https://example.com);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(site);
CookieContainer cookieContainer = new CookieContainer();
request.CookieContainer = cookieContainer;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
var myCookie = cookieContainer.GetCookieHeader(site);
}
and generate the following cookies :
Name1=Value1; Name2=Value2; Name3=Value3
supposing I want to change the value of cookie Name2 to "replaceValue2" and I want to add cookies (name4=value4). The following is an example of the results I want ...
Name1=Value1; Name2=replaceValue2; Name3=Value3; Name4=Value4