Reputation: 1595
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]);
Upvotes: 0
Views: 1687
Reputation: 96984
Have you tried putting an NSURL
into the NSHTTPCookieOriginURL
property?
NSURL *originURL = [NSURL URLWithString:@"http://www.mydomain.com"];
It looks like you can use an NSString
or an NSURL
, 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.
Upvotes: 1