Stack Exchange
Issue while sending cookie to URL with UIWebView
I have to open a URL in UIWebview with a cookie. I have to send a cookie to UIWebView. Only if the cookie value will correct then webview will load.
Here is my setup:
In my appDelegate's method 
 - (void)applicationDidBecomeActive:(UIApplication *)application 
  {
      [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];

   }

This is how I am creating cookie and loading request in ViewController's viewDidLoad method:
//Set Cookie
NSMutableDictionary *cookieProperties = [NSMutableDictionary dictionary];
[cookieProperties setObject:@"username" forKey:NSHTTPCookieName];
[cookieProperties setObject:cookieValue forKey:NSHTTPCookieValue];
[cookieProperties setObject:@".xyz.com" forKey:NSHTTPCookieDomain];
[cookieProperties setObject:@"/" forKey:NSHTTPCookiePath];

[cookieProperties setObject:[[NSDate date] dateByAddingTimeInterval:2629743] forKey:NSHTTPCookieExpires];

NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties:cookieProperties];
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie];

//Create Reqeust
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:completeURL]];

[_webView loadRequest:request];

Issue I am facing
It only works in my simulator. I tested in device and on other mac's it is not working. And sometimes it is not even works in my system.
I am unable to find what is the reason behind it?

check this link http://stackoverflow.com/questions/5954382/ios-is-it-possible-to-set-a-cookie-manually-using-sharedhttpcookiestorage-for-a @rahul

@PrissyEve I wrote this by using same link as a reference.
