NSHTTPCookie does not permanently remove cookies while WKWebView instance exists

Originator:fatchicksinpartyhats
Number:rdar://20417093 Date Originated:03-Apr-2015 10:36 AM
Status:Open Resolved:
Product:iOS SDK Product Version:8.2
Classification:Other Bug Reproducible:Always
 
Summary:
A session/login cookie gathered while using a WKWebView is not permanently removed when using NSHTTPCookieStorage.sharedHTTPCookieStorage().deleteCookie. This only works if the WKWebView instance is removed from the view stack and nil’d out before calling deleteCookie.

Steps to Reproduce:
1. Use a WKWebView instance to log into a site with a known login cookie. In my case it was a Rails server using out-of-the-box cookie-based session management.
2. Observe that NSHTTPCookieStorage.sharedHTTPCookieStorage().cookies contains the expected cookie
3. Loop through all cookies and, for each, delete it using NSHTTPCookieStorage.sharedHTTPCookieStorage().deleteCookie(cookie)
4. Observe that is now an empty collection
5. Quit the application via double home button tap and swipe up to toss the card away
6. Restart the application and observe that SHTTPCookieStorage.sharedHTTPCookieStorage().cookies contains the cookie that was supposedly deleted

Expected Results:
The cookies that were deleted using deleteCookie() stay deleted.

Actual Results:
The cookies that were deleted using deleteCookie() are not deleted after restarting the application.

Regression:
Unknown

Notes:
This can be seen on both the iOS 8.2 Simulator and hardware – iPad 2, in my case. The solution for this is to run removeFromSuperview() on the associated WKWebView instance, nil it out, then attempt to delete cookies.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!