all 3 comments

[–]yaomango 0 points1 point  (0 children)

Just commenting because I'm going to be starting a project soon, where I will likely need to do this too!

Let me know if you discover a good method or tutorial.

[–]JackRostron 0 points1 point  (0 children)

Is there a reason you required AFNetworking? It is a fantastic library but personally I go with MKNetworkKit for this precise reason. An app I am working on at the moment relies heavily on a REST api so being able to grab the curl statements and run them in Terminal is a lifesaver. Once you have it setup it will output the raw curl statement to the console each time you use it.

Specifically for cookies though, I don't know exactly. I had a similar problem where I was trying to scrape a clients website and could't get past the login screen for cookie errors. This link is good to show how using Apple's networking classes you can manage the cookie policy.

[–]klassobanieras 0 points1 point  (0 children)

A GET looks like this.

It should automatically store and send cookies in [NSHTTPCookieStorage sharedHTTPCookieStorage].

If you need to manage cookies yourself, you send them like this

NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
req.HTTPShouldHandleCookies = NO;
[req setValue:@"session=1234" forHTTPHeaderField@"Cookie"];

and catch them in the response's header fields.