According to Apple documentation:
... cookies are shared among all applications and are kept in sync across process boundaries.
But there is this iOS Note:
Cookies are not shared among applications in iOS.
So basically I can not use cookies from Safari inside my app?
iOS security sandbox disables cookie sharing amongst apps using
WKWebViewas you've discovered with the iOS note and there's no way around this. You can share cookies between multipleWKWebView's inside your app by utilisingWKProcessPool.There is a way of passing cookie data from Safari to your app by combining
SFSafariViewController(iOS 8 and below you will need to switch to Safari) with a custom URL scheme.The fundamentals of this approach would be:
SFSafariViewController(or launch Safari[[UIApplication sharedApplication] openURL:url]for iOS8 and below)urlwould attempt to load your custom URL scheme passing cookie data i.e.my-custom-scheme:cookie=value- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotationThe user will however see the Safari View Controller pop up then close (or switch between apps for iOS8 and below). There isn't a silent way of doing this (extra: There are ways to force the main window to be above the
SFSafariViewControllerhowever this isn't supported by Apple).