title: Odata Client with Cookie
body: <p>The following code has been implemented to get JsessioniD from the Cookies. The webSite uses form authentication. </p>
  
  <p>Here is what I have implemented.</p>
  
  <pre><code>public override void ViewDidLoad ()
    {
      base.ViewDidLoad ();
      using(var client= new CookieAwareWebClient())
      {
          var values= new NameValueCollection
             {
               {"username","admin"},
               {"password","admin"},
             };
              client.UploadValues("myURL/j_security_check",values);
              Cookie jSessionID = client.ResponseCookies["JSESSIONID"];
              if (jSessionID != null)
              {
                  // get the JEssionID here
                 string value = jSessionID.Value;
               }
      };
  }
  
  public class CookieAwareWebClient : WebClient
  {
      public CookieAwareWebClient()
      {
          CookieContainer = new CookieContainer();
          this.ResponseCookies = new CookieCollection();
      }
  
      public CookieContainer CookieContainer { get; private set; }
      public CookieCollection ResponseCookies { get; set; }
  
      protected override WebRequest GetWebRequest(Uri address)
      {
          var request = (HttpWebRequest)base.GetWebRequest(address);
          request.CookieContainer = CookieContainer;
          return request;
      }
  
      protected override WebResponse GetWebResponse(WebRequest request)
      {
          var response = (HttpWebResponse)base.GetWebResponse(request);
          this.ResponseCookies = response.Cookies;
          return response;
      }
  }
  </code></pre>
  
  <p>I get the JSessionID, and now my question is how to make call to odata client with cookie header?</p>