Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WKWebView cookie storage location

I am transitioning an app from UIWebView to WKWebView and there's an auto login feature that was handled by saving a cookie with the information that the user was authenticated into NSHTTPCookieStorage. However WKWebView does not seem to look at this location for the cookie and therefore the user is prompted with the login screen every time.

Is there something I need to activate to have the WKWebView use cookies properly?

like image 935
JMD Avatar asked Jan 19 '15 15:01

JMD


People also ask

Does WKWebView store cookies?

The current app manages the users login / session outside of the webview and sets the cookies required for authentication into the the NSHTTPCookieStore . Unfortunately new WKWebView doesn't use the cookies from the NSHTTPCookieStorage .

Does WKWebView share cookies with Safari?

WKWebView is an in-app browser that displays web content. It doesn't share cookies or web site data with other WKWebView instances, or with the Safari browser.

Where are cookies stored iPhone apps?

To check where are the app cookies stored on iPhone, On an iPhone, go to Settings -> Safari -> Advanced -> Website Data and you will see all cookies stored on your device. For iOS Application using web view The UIWebView will automatically store the cookies in the sharedHTTPCookieStorage.

What is the difference between UIWebView and WKWebView?

Unlike UIWebView, which does not support server authentication challenges, WKWebView does. In practical terms, this means that when using WKWebView, you can enter site credentials for password-protected websites.


1 Answers

For now WKWebView and UIWebView does not co-work properly together, due to not sharing of same cookie storage space. It is been discussed in depth in following answer. How can I retrieve a file using WKWebView?

Lets hope Apple fix this in upcomming update.

like image 137
bllakjakk Avatar answered Oct 01 '22 02:10

bllakjakk