Hi, I’m using the following code for FaceBook authentication with custom cookie management (-setHTTPShouldHandleCookies:NO), but recently it has stopped working with a web message ‘Cookies are not enabled’.
It does work if I set -setHTTPShouldHandleCookies:YES, but I don’t want to share cookies with Safari. Is there a workaround for this? Thank you. - (void)handleCookiesForResponse:(NSURLResponse *)response; { if ([response respondsToSelector:@selector(allHeaderFields)]) { // grab the cookies from the header as NSHTTPCookies and store them locally NSDictionary *headers = [(NSHTTPURLResponse *)response allHeaderFields]; if (headers) { NSURL *url = [response URL]; NSArray *cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:headers forURL:url]; if ([cookies count] > 0) { [cookieStorage_ setCookies:cookies]; } } } } - (NSURLRequest *)addCookiesToRequest:(NSURLRequest *)request; { // override WebKit's usual automatic storage of cookies NSMutableURLRequest *mutableRequest = [[request mutableCopy] autorelease]; [mutableRequest setHTTPShouldHandleCookies:NO]; // add our locally-stored cookies for this URL, if any NSArray *cookies = [cookieStorage_ cookiesForURL:[request URL]]; if ([cookies count] > 0) { NSDictionary *headers = [NSHTTPCookie requestHeaderFieldsWithCookies:cookies]; NSString *cookieHeader = [headers objectForKey:@"Cookie"]; if (cookieHeader) { [mutableRequest setValue:cookieHeader forHTTPHeaderField:@"Cookie"]; } } return mutableRequest; } -- Best regards, Mirko _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com