views:

17

answers:

1

I am saving a cookie value and then trying to send it back with a later request to use for authentication... it doesn't seem to be working.

  NSString *savedCookie = [savedData objectForKey:@"savedLoginCookie"];
  NSMutableURLRequest *requestObj = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlAddress]];
  [requestObj addValue:savedCookie forHTTPHeaderField:@"persistId"];

"persistID" is the name of the cookie [cookie name] and savedCookie is the string value of the cookie [cookie value]

I obtained these from an earlier request with the code below:

for (NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies])
{
    if ([[cookie name] isEqualToString:@"persistId"])
    {
        NSString *savedCookie = [cookie value];
        //Save Cookie
        NSUserDefaults *savedData = [NSUserDefaults standardUserDefaults];
        [savedData setObject:savedCookie forKey:@"savedLoginCookie"];   

    }

}
A: 

NO PROBLEM... CODE WAS WORKING FINE.

Ben Call