Doggo Dog

Doggo Dog

  • 2k
  • 2
  • 3.6k

C# Get cookies created in JavaScript

Oct 18 2017 8:10 AM
So I stumbled on this problem while creating a application that get's cookies from a website. For some reason the program only outputs a few cookies instead of every single one, somebody told me it might be because some cookies are created with JavaScript. Is it possible making this still in C#,
 
Thanks. 
 
  1. string url = textBox1.Text;  
  2. var cookies = new CookieContainer();  
  3. HttpWebRequest myCall = (HttpWebRequest)WebRequest.Create(url);  
  4. myCall.CookieContainer = cookies;  
  5. HttpWebResponse response = (HttpWebResponse)myCall.GetResponse();  
  6. myCall.AllowAutoRedirect = true;  
  7. myCall = (HttpWebRequest)WebRequest.Create(url);  
  8. myCall.CookieContainer = cookies;  
  9. foreach (Cookie cookie in response.Cookies)  
  10. {  
  11. Console.WriteLine(cookie.Name);  
  12. Console.Read();  
  13. }  
  14. myCall.Abort();  
 

Brought to you by:

Answers (1)