title: Login to website and use cookie to get source for another page
body: <p>I am trying to login to the TV Rage website and get the source code of the My Shows page.  I am successfully logging in (I have checked the response from my post request) but then when I try to perform a get request on the My Shows page, I am re-directed to the login page.</p>
  
  <p>This is the code I am using to login:</p>
  
  <pre><code>    private string LoginToTvRage()
      {
          string loginUrl = "http://www.tvrage.com/login.php";
          string formParams = string.Format("login_name={0}&amp;login_pass={1}", "xxx", "xxxx");
          string cookieHeader;
          WebRequest req = WebRequest.Create(loginUrl);
          req.ContentType = "application/x-www-form-urlencoded";
          req.Method = "POST";
          byte[] bytes = Encoding.ASCII.GetBytes(formParams);
          req.ContentLength = bytes.Length;
          using (Stream os = req.GetRequestStream())
          {
              os.Write(bytes, 0, bytes.Length);
          }
          WebResponse resp = req.GetResponse();
          cookieHeader = resp.Headers["Set-cookie"];
          String responseStream;
          using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
          {
              responseStream = sr.ReadToEnd();
          }
          return cookieHeader;
      }
  </code></pre>
  
  <p>I then pass the <code>cookieHeader</code> into this method which should be getting the source of the My Shows page:</p>
  
  <pre><code>    private string GetSourceForMyShowsPage(string cookieHeader)
      {
          string pageSource;
          string getUrl = "http://www.tvrage.com/mytvrage.php?page=myshows";
          WebRequest getRequest = WebRequest.Create(getUrl);
          getRequest.Headers.Add("Cookie", cookieHeader);
          WebResponse getResponse = getRequest.GetResponse();
          using (StreamReader sr = new StreamReader(getResponse.GetResponseStream()))
          {
              pageSource = sr.ReadToEnd();
          }
          return pageSource;
      }
  </code></pre>
  
  <p>I have been using <a href="https://stackoverflow.com/questions/930807/c-login-to-website-via-program">this previous question</a> as a guide but I'm at a loss as to why my code isn't working.</p>