Below is my code snippet:
/*cookie attached in request part*/ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:httpsURL cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:5.0f]; [request setValue:@"cookie1=value1" forHTTPHeaderField:@"Cookie"]; /*cookie attached using NSHTTPCookie*/ NSMutableDictionary *cookieProperties = [NSMutableDictionary dictionary]; [cookieProperties setObject:@"cookie2" forKey:NSHTTPCookieName]; [cookieProperties setObject:@"value2" forKey:NSHTTPCookieValue]; [cookieProperties setObject:[request URL].absoluteString forKey:NSHTTPCookieOriginURL]; [cookieProperties setObject:@"/" forKey:NSHTTPCookiePath]; NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties:cookieProperties]; NSArray *arr = [NSArray arrayWithObjects:cookie, nil]; [request setAllHTTPHeaderFields:headers];
Now using the above configuration does my connection consider both the cookies during the request?
Your question doesn’t seem to gel with your post’s subject. In your post’s subject you mention NSHTTPCookieStorage but you never put a cookie into NSHTTPCookieStorage in the code example you show.
To answer the question from your post’s subject, the session’s cookie store (NSHTTPCookieStorage) is only consulted if you leave out the
Cookie header in request. If you want to get this sort of merging behaviour, you can fetch the cookies from the cookie store then merge in your cookies.
Share and Enjoy
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"