Hello Stackoverflow,
So I am trying to log into my site using an NSMutableURLRequest which presents the credentials via a post. As a noobie, I have some questions about the functionality of this method to make sure I am understanding it.
NSString *post = [NSString stringWithFormat:@"username=%@&password=%@&TARGET=%@",LoginId,LoginPwd,target];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setHTTPShouldHandleCookies:YES];
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://somelogin.mycomp.verify.fcc"]]];
//[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Current-Type"];
[request setHTTPBody:postData];
NSURLConnection *conn = [[NSURLConnection alloc]initWithRequest:request delegate:self];
Now this will automatically handle any redirects via the delegate method correct? It will also collect any cookies along the way? Also, should I be using an asynchronous request instead? Thanks!
UPDATE: So I have deduced that some of the cookies are being ignored by the request and subsequent redirects. Does anyone know why that may be happening?