How to delete WKWebview cookies

后端 未结 13 1501
北荒
北荒 2020-11-27 04:18

For now I am doing like this

    NSHTTPCookie *cookie;
    NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
    for (cookie in [         


        
13条回答
  •  一向
    一向 (楼主)
    2020-11-27 04:52

    Esqarrouth's answer is only partially right.
    The correct swift version is:

    var libraryPath : String = NSFileManager().URLsForDirectory(.LibraryDirectory, inDomains: .UserDomainMask).first!.path!
    libraryPath += "/Cookies"
    do {
        try NSFileManager.defaultManager().removeItemAtPath(libraryPath)
    } catch {
        print("error")
    }
    NSURLCache.sharedURLCache().removeAllCachedResponses()
    

提交回复
热议问题