Reputation: 7242
My Cocoa app uses WebView
to open pages that uses cookies. For testing purposes I want to remove those cookies. How can I do this (programmatically or manually) ?
Upvotes: 3
Views: 3504
Reputation: 15003
Originally, cookies were shared between apps on Mac OS X. So you could use the Safari preferences to remove all cookies.
However, as of OS X 10.11, that potential security hole has been closed, and all apps have their own cookie store. (and even before that, sandboxed apps had their own cookie store too)
Upvotes: 3
Reputation: 386
If you wanted to do it programmatically, you can use NSHTTPCookieStorage
You'll need cookiesForURL:
and deleteCookie:
. Something a little like this (untested):
NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (NSHTTPCookie *cookie in [cookieJar cookiesForURL:@"http://myserver.com"])
{
[cookieJar deleteCookie:cookie];
}
Upvotes: 6