C# Get JavaScript created cookies? RRS feed

  • Question

  • Hi, while I was making my console application to get cookies from a website I noticed my program didn't output all cookies on the website, people told me it was due some cookies being created with JavaScript. My question is if it's possible to still get all cookies with c#

    string url = ""
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    request.CookieContainer = new CookieContainer();
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    request.AllowAutoRedirect = false;
    foreach (Cookie cookie in response.Cookies)
    string CookieName = cookie.Name;
    Console.WriteLine(CookieName + " / " + cookie.Value);


    • Edited by CodingDoggo Thursday, October 19, 2017 3:53 PM
    Thursday, October 19, 2017 12:50 PM

All replies

  • Cookies would be on a client machine, not a server. You didn't mention what type of application you wrote. If it is a web app then please post in the ASP.NET forums

    Michael Taylor

    Thursday, October 19, 2017 3:05 PM
  • Hi, I have edited my question.
    Thursday, October 19, 2017 3:48 PM
  • You're not going to get the cookies from the client using that code. The only cookies you would get are the cookies that the browser sends back explicitly. This isn't going to include client-side only cookies in most cases. It would completely depend upon the client side implementation.

    Michael Taylor

    Thursday, October 19, 2017 3:55 PM