2

I am using the UIWebView to load the URL. I want to know how to clear the Cookies in that .

Perseus
  • 1,546
  • 4
  • 30
  • 55
  • 1
    possible duplicate of [How to delete all cookies of UIWebView?](http://stackoverflow.com/questions/4471629/how-to-delete-all-cookies-of-uiwebview) – jscs May 23 '12 at 05:04

2 Answers2

15

You can go through each cookie in the cookie jar and remove them.

How to delete all cookies of UIWebView?

NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies]) 
{
   [storage deleteCookie:cookie];
}
Community
  • 1
  • 1
Brandon Schlenker
  • 5,078
  • 1
  • 36
  • 58
  • Actually, I got this code when I googled. But implemented in wrong place. Now changed to proper place . It works. Thank you !!! – Perseus May 16 '12 at 11:15
1
NSHTTPCookie *cooki;
NSHTTPCookieStorage *data = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cooki in [data cookies]) {
   [data deleteCookie:cooki];
}
Saad
  • 8,857
  • 2
  • 41
  • 51