title: How do I get CSRFToken cookie in C#?
body: <p>ok i might be dumb cause im the only one asking this kind of question since i saw no similar questions but excuse me for that :|. quarantine just keep making me tryna learn more programming languages, got nothin to do. sorry if i kept asking for solutons everytime. cause i've tried researching for it and got nothing.</p>
  <p><strong>Anyway</strong>, so I tried to retrieve Cookies from a Shopping webpage with <code>System.Net.Http;</code> which supposed to be having the csrftoken in the Browser cookies. I tried using Python before but I got no cookies retrieved, but for some reason with C#, I got some retrieved. However, I didn't recieve the csrftoken cookie. I think it's because the cookie was based on browser session? :/. <a href="https://stackoverflow.com/questions/46007756/c-getting-403-even-after-sending-csrf-token-using-httpclient">I've seen this guy getting his csrftoken, but reading the code is a bit confusing for me.</a> How do I retrieve the csrftoken session cookie?.</p>
  <p><strong>This is the code that I'm currently using anyway.</strong></p>
  <pre><code>            try
          {
              CookieContainer container = new CookieContainer();
              HttpWebRequest request = (HttpWebRequest)WebRequest.Create(&quot;https://shopee.co.id/&quot;);
              request.Proxy = null;
              request.CookieContainer = container;
              request.UserAgent = &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36&quot;;
              request.Referer = &quot;https://shopee.co.id&quot;;
              request.Headers.Add(&quot;authority&quot;, &quot;shopee.co.id&quot;);
              using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
              {
                  foreach (Cookie cookie in response.Cookies)
                  {
                      Console.WriteLine(&quot;Name =&quot; + cookie.Name);
                      Console.WriteLine(&quot;Value =&quot; + cookie.Value);
                      Console.WriteLine(&quot;Path =&quot; + cookie.Path);
                      Console.WriteLine(&quot;Domain =&quot; + cookie.Domain);
                  }
              }
          }
  </code></pre>