[Webkit-unassigned] [Bug 198554] Unable to get cookies from WKWebView

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jun 5 14:01:41 PDT 2019


https://bugs.webkit.org/show_bug.cgi?id=198554

--- Comment #4 from Sihui Liu <sihui_liu at apple.com> ---
(In reply to Jeremy Schonfeld from comment #0)
> Created attachment 371369 [details]
> Cookies shown in the safari web inspector after passing the login page in
> the iOS simulator
> 
> I am currently using a WKWebView to authenticate a user via a website in my
> app. Ideally, the web view is presented, the user enters login information,
> the website responds with the proper authentication cookies, and then the
> app retrieves the cookies from the web view to use in later background
> URLSession requests. However, I am unable to get the cookies after login. I
> can clearly see through the Safari web inspector that the cookies appear
> after moving past the login page (see attached screenshot). However, I
> cannot retrieve the cookies via code. I tried setting the view controller as
> the WKHTTPCookieStoreObserver with
> "webView.configuration.websiteDataStore.httpCookieStore.add(self)" in
> viewDidLoad() of the view controller, but the delegate method
> "cookiesDidChange" is never called. Additionally, I attempt to call
> "webView.configuration.websiteDataStore.httpCookieStore.getAllCookies" in
> webView didFinish navigation, however the callback only returns the cookies
> half of the time seemingly randomly. The other half of the time, the
> callback returns an empty list or other cookies (not the authentication
> cookies I see in the web inspector). This issue is blocking me from adding a
> functioning login view to my app. I spoke to some of the WebKit developers
> (Chris and John) at the WWDC lab today.

Do you have web inspector open when you try to get all cookies from httpCookieStore?

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20190605/33d711b2/attachment.html>


More information about the webkit-unassigned mailing list