1

Is the policy on iOS UIWebview is to accept all cookies by default or to block them?

If it is to block, how would I change this policy?

Thanks

Michael

Alon Amir
  • 4,913
  • 9
  • 47
  • 86
Mike
  • 241
  • 1
  • 13

1 Answers1

2

The cookie policy is managed by:

[NSHTTPCookieStorage sharedHTTPCookieStorage].cookieAcceptPolicy

And the default value is:

NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain

Which is, to accept cookies only from your main document domain (the domain of the currently opened html document).

The relevant enum is:

typedef NS_ENUM(NSUInteger, NSHTTPCookieAcceptPolicy) {
    NSHTTPCookieAcceptPolicyAlways,
    NSHTTPCookieAcceptPolicyNever,
    NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain
};
Alon Amir
  • 4,913
  • 9
  • 47
  • 86
  • Hi Alon - thanks for that. Does that mean that when the request is initially made and a cookie is stored - then, by default, that cookie will be in use during that session until the user closes the application? – Mike Aug 14 '15 at 10:32
  • Hi, you can see further details of the cookies life cycle and management here: http://stackoverflow.com/questions/9273063 – Alon Amir Aug 14 '15 at 10:37
  • @Mike "Does that mean that when the request is initially made and a cookie is stored": Yes. "by default, that cookie will be in use during that session until the user closes the application": Yes, however the cookies will also remain after the user restarts the app. – Alon Amir Aug 14 '15 at 11:00