title: IOS UIWebView add Cookie value to request
body: <p>New to Xcode and I want to load a page into a UIWebView but set a cookie with the request. I can NSLog the cookie value so I know it's set.</p>
  
  <p>Here is what I'm doing at the moment:</p>
  
  <pre><code>-(IBAction)displayRedZones:(id)sender
  {
     NSLog(@"red zones");
     UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(25/100 * (float)self.view.bounds.size.width, 25/100 * (float)self.view.bounds.size.height, (float)self.view.bounds.size.width / 2, (float)self.view.bounds.size.height / 2)];
  
     NSString* combinedString = [self.urlToLoad stringByAppendingString:@"/redzone"];
     NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies];
  
      NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: combinedString] cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval: 1];
  
  
      [request setHTTPShouldHandleCookies:YES];
  
      webView.scalesPageToFit = YES;
      webView.delegate = self;
      [self addCookies:cookies forRequest:request];
      [webView loadRequest: request];
      [self.view addSubview:webView];  
  }
  
  - (void)addCookies:(NSArray *)cookies forRequest:(NSMutableURLRequest *)request
  {
      NSString *cookieHeader = nil;
      NSString* cookieValue = [@"CAKEPHP" stringByAppendingString:self.cookieValue];
      [request setValue:cookieHeader forHTTPHeaderField:@"Cookie"];
  }
  </code></pre>