title: Can't set cookie in NSURLRequest
body: <p>In my program I call two functions, the first a a login, the second one a function to parse data.</p>
  
  <p>To store session, with the login function I save my cookies with this:</p>
  
  <pre><code>- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
  {
      [receivedData setLength:0];
      if(connection == conn_login){
          NSHTTPURLResponse *HTTPResponse = (NSHTTPURLResponse *)response;
          NSDictionary *fields = [HTTPResponse allHeaderFields];
          cookie = [fields valueForKey:@"Set-Cookie"];
      }
  }
  </code></pre>
  
  <p>Everything is fine, when I print cookie it is:</p>
  
  <pre><code>userid=1; expires=Mon, 05-Aug-2013 19:22:18 GMT; path=/; domain=www.mydomain.com
  </code></pre>
  
  <p>"userid=1" is what I'm interested in.</p>
  
  <p>So in the following NSURLRequest where I parse the data, I do like this to set the saved cookie:</p>
  
  <pre><code>NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL
  URLWithString:@"http://www.mydomain.com/?getList"]];
  [request setValue:cookie forHTTPHeaderField:@"Set-Cookie"];
  </code></pre>
  
  <p>But it doesn't work. My previous cookies are not set, and even if a print the complete header of the 2nd request, there is no "userid" or whatsoever.</p>
  
  <p>What am I doing wrong? Thank you all.</p>