Skip to content

Instantly share code, notes, and snippets.

@steveriggins
Last active December 23, 2015 14:59
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveriggins/6652508 to your computer and use it in GitHub Desktop.
Save steveriggins/6652508 to your computer and use it in GitHub Desktop.
iOS 7 has a bug (or made a design decision which goes against the documentation) to set the cookie policy of NSURLConnections to whatever the user has set their cookie preferences to via Settings -> Safari. This simple method resets the cookie policy to accept always. Apple documentation for cookieAcceptPolicy: https://developer.apple.com/librar…
- (void)takeControlOfTheCookies
{
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self takeControlOfTheCookies];
// ...
}
// If you want to be extra sure...
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[self takeControlOfTheCookies];
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment