How to delete cookies stored in WebView in Cocoa app?

In my application, Cocoa is used WebViewto open pages that use cookies. For testing purposes, I want to delete these cookies. How to do it (programmatically or manually)?

+3
source share
2 answers

Cookies were originally distributed between applications on Mac OS X. In this way, you can use Safari settings to delete all cookies.

However, with OS X 10.11, this potential security hole is closed, and all applications have their own cookie store. (and even before that, isolated applications had their own cookies)

+2
source

If you want to do this programmatically, you can use NSHTTPCookieStorage

You will need cookiesForURL:and deleteCookie:. Something like this (unverified):

NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];

for (NSHTTPCookie *cookie in [cookieJar cookiesForURL:@"http://myserver.com"]) 
{
  [cookieJar deleteCookie:cookie];
}
+6
source

Source: https://habr.com/ru/post/1772717/


All Articles