How to manage cookies with UIWebView in Swift

后端 未结 8 890
心在旅途
心在旅途 2020-12-02 11:53

What about have a topic where people can easily see how to manage cookies in a webview using the new language Swift? If you check in internet you won\'t find anything intere

8条回答
  •  忘掉有多难
    2020-12-02 12:20

    If you are working on swift 4 then this code will disable cookies and also remove the URL cache.

    let cookieJar : HTTPCookieStorage = HTTPCookieStorage.shared
    for cookie in cookieJar.cookies! as [HTTPCookie]{
        NSLog("cookie.domain = %@", cookie.domain)
         cookieJar.deleteCookie(cookie)
    }
    
    URLCache.shared.removeAllCachedResponses() 
    URLCache.shared.diskCapacity = 0 
    URLCache.shared.memoryCapacity = 0
    

提交回复
热议问题