WKWebView and UIWebView Cookie

Hello,


Our apps are using cookies to login mechanism.

And determining the user's information with reference to the value written to it.

For example:

* Is the user logged in?

* Who is the user corresponding to the ID?


Technically, we read and write the cookie value from NSHTTPCookieStorage through UIWebView in the app or SDK.


In WWDC2016 security session, there was a presentation of the ATS.

We'll not be able to continue to use the UIWebView in order to cope with the ATS.

So, we are considering changes to the WKWebView from UIWebView.


I'd like to ask you the following two questions.


1. data sync direction between WKWebsiteDataStore and NSHTTPCookieStorage


According to research, I got below:

* WKWebView use WKWebsiteDataStore class to manage cookie

* WKWebsiteDataStore sync data with NSHTTPCookie Storage


Which is data sync direction is?


a. WKWebsiteDataStore → NSHTTPCookieStorage

b. NSHTTPCookieStorage → WKWebsiteDataStore

c. NSHTTPCookieStorage → WKWebsiteDataStore or WKWebsiteDataStore → NSHTTPCookieStorage


2. When is the timing of syncing data between WKWebsiteDataStore and NSHTTPCookieStorage?


According to research data sync behavior, I got below:

* WKWebsiteDataSource sync data with NSHTTPCookieStorage randomly, and it's timing is not able to control manually


When is the timing of syncing data?

And, can we sync programmatically?


Thanks,

Takuya Yokoyama

Replies

Dear apple, i have the same question,hope give us some suggestions soon.thank you.

Same here, I was hoping that in iOS 10 WKWebView will get some improvements in this area, but I didnt see much.

there are some workarouds, e.g. see here: http://stackoverflow.com/questions/26573137/can-i-set-the-cookies-to-be-used-by-a-wkwebview

But publik API would be better, ot at least switch somewhere to enable sychronization or ...