title: How to get cookies and use them for other requests like POST ( iOS )?
body: <p>My <a href="https://stackoverflow.com/questions/12538782/how-to-remain-logged-in-until-user-decides-to-logout/">previous question</a> was about the problem that I have to login each time for doing web services like posting a link or uploading a picture. Philipe answered that I have to use cookies instead of login process for each request. I found this method for getting cookies:</p>
  
  <pre><code>- (void)getCookies {
  
      NSHTTPURLResponse * response;
      NSError * error;
      NSMutableURLRequest *request;
  
      request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://MyWebsite.com/login.php"]
                                              cachePolicy:NSURLRequestReloadIgnoringCacheData
                                          timeoutInterval:120];
      NSData * data = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error];
  
      NSLog(@"%@", [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]);
      NSArray * all = [NSHTTPCookie cookiesWithResponseHeaderFields:[response allHeaderFields] forURL:[NSURL URLWithString:@"http://MyWebsite.com/login.php"]];
      NSLog(@"%d", all.count);
  
      for (NSHTTPCookie *cookie in all) {
          NSLog(@"Name: %@ : Value: %@", cookie.name, cookie.value);
          NSLog(@"Comment: %@ : CommentURL: %@", cookie.comment, cookie.commentURL);
          NSLog(@"Domain: %@ : ExpiresDate: %@", cookie.domain, cookie.expiresDate);
          NSLog(@"isHTTPOnly: %c : isSecure: %c", cookie.isHTTPOnly, cookie.isSecure);
          NSLog(@"isSessionOnly: %c : path: %@", cookie.isSessionOnly, cookie.path);
          NSLog(@"portList: %@ : properties: %@", cookie.portList, cookie.properties);
          NSLog(@"version: %u", cookie.version);
      }
  } 
  </code></pre>
  
  <p>I also found this code to use these cookies, but I'm not sure how to use it:</p>
  
  <pre><code>[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookies];
  </code></pre>
  
  <p>Here is my method for POSTing, I am using RestKit API:</p>
  
  <pre><code>- (IBAction)addLinkPressed:(UIButton *)sender {
  
          [RKClient clientWithBaseURLString:@"http://MyWebsite.com"];
  
          NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys:
                                  self.linkField.text, @"url",
                                  self.linkTitleField.text, @"title",
                                  self.linkSummaryField.text, @"summary",
                                  nil];
  
          RKRequest *request = [[RKClient sharedClient] post:@"/send_link.php" params:params delegate:self];
          [request setUserData:@"sendLink"];   
  }
  </code></pre>
  
  <p><strong>Question:</strong> Which property of cookies should I store to use it for login information and where should I put it in my code?</p>