I do this, but the new cookie doesn’t show up, just some other cookies that are already set. What’s wrong?
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:[NSHTTPCookie cookieWithProperties:[NSDictionary dictionaryWithObjectsAndKeys:
@"www.mydomain.com", NSHTTPCookieOriginURL,
@"/", NSHTTPCookiePath,
@"mycookiename", NSHTTPCookieName,
@"mycookievalue", NSHTTPCookieValue,
nil]]];
NSLog(@"%@",[NSHTTPCookieStorage sharedHTTPCookieStorage]);
Have you tried putting an
NSURLinto theNSHTTPCookieOriginURLproperty?It looks like you can use an
NSStringor anNSURL, but either way the URL you specify must conform to the standards outlined in RFC 2396 (e.g. “http://x.y.z“, etc.).Also make sure you’re not overlooking any other required cookie properties or formatting of those properties.