tags:

views:

3356

answers:

1

I'm building an iPhone app with cookies. Deleting cookies in the Safari settings doesn't delete them. Where are they stored? Is it possible to read them from another UIWebView?

Thanks!

+16  A: 

Your application has its own "cookie jar" in the [NSHTTPCookieStorage sharedHTTPCookieStorage] container.

Here's how you might take a quick look at the cookies in your application:

NSHTTPCookie *cookie;
for (cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {
   NSLog(@"%@", cookie);
}

Several methods are available for filtering and manipulation. Take a look at the NSHTTPCookieStorage documentation for accessing cookies, and the NSHTTPCookie documentation for accessing individual cookie properties.

Alex Reynolds
That's interesting. I didn't know such a thing existed. Thanks for pointing it out.
Brad Larson
Thanks, Alex! Exactly what I was looking for.
dot