title: Caching Cookies in inappbrowser iOS 10(clearcache=no;) not working when app restarts - Cordova/Ionic
body: <p>I am facing an issue in an ionic iOS application where my website is not saving cookies and clear cache and clear session cache are not working.
  I am using Cordova Inappbrowser plugin.</p>
  
  <p>In Android, it is working perfectly.</p>
  
  <pre><code>var ref = window.open(url, '_blank','location=no,toolbar=yes,clearcache=no,clearsessioncache=no');
  </code></pre>
  
  <p>But, in iOS, it is not working. When, I first provide my credentials, and go into the app and then I exit the app and reopen it, it again asks for my credentials( Which works perfectly in ANDROID )</p>
  
  <p>Upon further digging, I found that the cookie which was meant to be saved are marked as <strong>isSessionOnly=true and expires=null</strong>.</p>
  
  <p>Thus, I can see the cookie inside the session but gets cleared when an app is closed</p>
  
  <p>I found my result by writing the following code in CDVinAppbrowser.m class:</p>
  
  <pre><code>- (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
     {     
         NSHTTPCookie *cookie;
         NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
      for (cookie in [cookieJar cookies]) {
         NSLog(@"%@", cookie);
      }
  </code></pre>
  
  <p>So, how to save cookies or make the inappbrowser with options working with clearcache=no and clearsessioncache=no in iOS.</p>
  
  <p>Note: I am completely new to iOS/Swift. So, I need to know where to place the code in the swift classes.</p>
  
  <p><strong>Edit for Bounty (by AndroidMechanic)</strong></p>
  
  <p>I have the exact same problem where it works for android flawlessly but on iOS it asks for credentials every time the app restarts. I'm offering a bounty for a solution where native code can be avoided.</p>