在 WKWebView 中禁用 cookie

Disabling cookies in WKWebView

是否可以在 WKWebView 中禁用 cookie 和本地存储?

假设这是我的设置,我想添加一些禁用它们的东西:

import UIKit
import WebKit

class ViewController: UIViewController, WKUIDelegate {

    var webView: WKWebView!

    override func loadView() {
        let webConfiguration = WKWebViewConfiguration()
        webView = WKWebView(frame: .zero, configuration: webConfiguration)
        webView.uiDelegate = self
        view = webView
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        let myURL = URL(string: "http://bla.com")
        let myRequest = URLRequest(url: myURL!)
        webView.load(myRequest)
    }


}

要禁用 cookie:

override func viewDidLoad() {
    super.viewDidLoad()
    let myURL = URL(string: "http://bla.com")
    var myRequest = URLRequest(url: myURL!)
    myRequest.httpShouldHandleCookies = false
    webView.load(myRequest)
}