2

In this question's most voted answer there is this line :

cookieJar.Add(new Cookie("my_cookie", "cookie_value", "/", "mysite"));

In this line, there are "my_cookie", cookie_value and "mysite" fields. I don't know how to fill these lines. Can you tell me how to fill those with an example? Thanks in advance.

Community
  • 1
  • 1
jason
  • 6,962
  • 36
  • 117
  • 198

2 Answers2

3

Hope this Helps

CookieContainer gaCookies = new CookieContainer();
Uri target = new Uri("http://www.google.com/");    
gaCookies.Add(new Cookie("__utmc", "#########") { Domain = target.Host });

or head here for more information

Lucifer
  • 1,594
  • 2
  • 18
  • 32
0

Try this:

HttpCookie _cookie = new HttpCookie("Department"); // Create and give name
_cookie.Expires = DateTime.Now.AddDays(30);       // expries in one month
_cookie.Value = "Dep1";                          // set value
HttpContext.Response.Cookies.Add(_cookie);      // add cookie to the context
Shaahin
  • 1,195
  • 3
  • 14
  • 22