public
Last active

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/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSHTTPCookieStorage_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40003665) Thanks to @cocoanetics for finding this and to @castirony for bringing it to my attention

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
- (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];
 
// ...
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.