title: AFNetworking and storing Cookies globaly
body: <p>I have an application where I use AFNetworking for networking.
  The service that I am talking to uses Basic Auth for authentication.
  So in my client I use the setAuthorizationHeaderWithUsername:password: method to set username and password and everything works fine.</p>
  
  <p>Now I should add a "open in Browser" button to the app. But when I call the URL, Safari on my iPhone/iPad will want the user to login again.</p>
  
  <p>Is there any solution I can set the cookie that I get when logging in into the default cookie store?</p>
  
  <p>What I tried so far is this:</p>
  
  <pre><code>NSString* authorization = [client defaultValueForHeader:@"Authorization"];
  NSMutableDictionary *cookieProperties = [NSMutableDictionary dictionary];
  [cookieProperties setObject:@"myCookie" forKey:NSHTTPCookieName];
  [cookieProperties setObject:authorization forKey:NSHTTPCookieValue];
  [cookieProperties setObject:@"www.the.server" forKey:NSHTTPCookieDomain];
  [cookieProperties setObject:@"www.the.server" forKey:NSHTTPCookieOriginURL];
  [cookieProperties setObject:@"/" forKey:NSHTTPCookiePath];
  [cookieProperties setObject:@"0" forKey:NSHTTPCookieVersion];             
  [cookieProperties setObject:[[NSDate date] dateByAddingTimeInterval:2629743] forKey:NSHTTPCookieExpires];
  
  NSHTTPCookie* cookie = [[NSHTTPCookie alloc] initWithProperties:cookieProperties];
  [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie];
  [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
  </code></pre>
  
  <p>This gives me a cookie, but when opening the URL in Safari on my iPhone/iPad it's not working</p>
  
  <p>Is there any API call in AFNetworking that will handle that? Or is there a way I can do it myself manually?</p>
  
  <p>Thanks for helping</p>