I made a change to the CookieAcceptPolicy in NSHTTPCookieStorage in my app:
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyNever];
When I use the following code to restore its settings:
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain];
WKWebView still does not store cookies. I found that in iOS 17, the cookie policy for WKWebView can be enabled through the following configuration:
[[[WKWebsiteDataStore defaultDataStore] httpCookieStore] setCookiePolicy:WKCookiePolicyAllow completionHandler:^{}];
But how can this be done in versions prior to iOS 17?