I'm working on a problem in my Mac OSX 10.5 application that requires deleting cookies on user sign-off from the application - so that a different user can sign-in without the need to quit the application. When user authenticates for the first time, the WebView receives and caches 5 cookies using the singleton cookie storage class NSHTTPCookieStorage. When I try to retrieve the cookies using [NSHTTPCookieStorage cookiesForURL:] method, I get only 4. Which means that the 5th one is associated with some other URL. I cannot use the domain to identify the cookies because I may land up deleting cookies being used by other applications. I am thinking along the following lines:
- Disable cookies for the WebView when loading the URL.
- I have tried using [NSMutableURLRequest setHTTPShouldHandleCookies:NO] but that didn't help. And I cannot change the cookie policy using NSHTTPCookieStorage because it will affect other applications.
- Retrieve the cookies for the URL that I am loading
- I don't know if this is possible. I searched all the delegate methods available for WebView but didn't find anything
- Do a fresh reload of the URL using [WebFrame reloadFromOrigin] instance method
- this is only available for Mac OSX >= 10.6
- Recreate the instance of WebView
- didn't help, cookies still persist
I have also tried different options provided by WebPreferences class, but that didn't help. Thanks in advance for any hints to fix this issue.