title: How to keep logged in session in UIWebview?
body: <p>I am using UIWebView in my app. I want to load a a URL on first webview, from that user can login his account. After login then User came out of the webview and do other stuffs in iOS native views.
  Later when he call the same URL, he must be logged in. How is it possible ?
  I hav seen this in Gmail when I logged in my account in one tab, and close it my GMAIl account is logged in safari whenever I open any tab.</p>
  
  <p>I have tried something below, but not working. Please suggest me a solution</p>
  
  <pre><code>   -(void)loadCookies
     {
     NSArray  *cookies       = [NSKeyedUnarchiver unarchiveObjectWithData: [[NSUserDefaults standardUserDefaults] objectForKey: @"cookies"]];
     NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
  
     for (NSHTTPCookie *cookie in cookies)
    {
      [cookieStorage setCookie: cookie];
     }
     }
  
  
  
   -(void)saveCookies
    {
  NSData         *cookiesData = [NSKeyedArchiver archivedDataWithRootObject:       [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]];
  NSUserDefaults *defaults    = [NSUserDefaults standardUserDefaults];
  [defaults setObject: cookiesData forKey: @"cookies"];
  [defaults synchronize];
   }
  </code></pre>
  
  <p>My apps flow is like below.</p>
  
  <p>1.Calling a URL on a UIWebview - <a href="http://www.userlogin.com" rel="noreferrer">http://www.userlogin.com</a>
  2.Poping from that view controller
  3.Doing other features in the app.
  4.Calling same URL in different UIWebView - <a href="http://www.userlogin.com" rel="noreferrer">http://www.userlogin.com</a></p>
  
  <p>Here I need to show his logged in session.</p>