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.
In Android, it is working perfectly.
var ref = window.open(url, '_blank','location=no,toolbar=yes,clearcache=no,clearsessioncache=no');
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 )
Upon further digging, I found that the cookie which was meant to be saved are marked as isSessionOnly=true and expires=null.
Thus, I can see the cookie inside the session but gets cleared when an app is closed
I found my result by writing the following code in CDVinAppbrowser.m class:
- (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
{
NSHTTPCookie *cookie;
NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [cookieJar cookies]) {
NSLog(@"%@", cookie);
}
So, how to save cookies or make the inappbrowser with options working with clearcache=no and clearsessioncache=no in iOS.
Note: I am completely new to iOS/Swift. So, I need to know where to place the code in the swift classes.
Edit for Bounty (by AndroidMechanic)
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.