I'm accessing a server's secure information and it sends a bunch of cookies to the App on request. The problem is some of the cookies are session only and when I use:
[NSHTTPCookie requestHeaderFieldsWithCookies:[[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:[NSURL URLWithString:theCookie]]
it doesn't return the session ones with the name JSESSIONID and causes issues. If I NSLog the full NSHTTPCookieStorage it displays the session ones so they are there, I just can't find a way to retrieve them out of the storage. Also, I've had a look through the cookie plist and the session cookies aren't stored there but I assume this is just due to them being session based.
Any help is appreciated.
Edit: This is a snippet of what I get when I ask for all cookies:
<NSHTTPCookie version:0 name:@\"TheNameOfTheCookie\" value:@\"A variable number\" expiresDate:@\"(null)\" created:@\"301196844.000000\" sessionOnly:TRUE domain:@\"THE URL\" path:@\"/\" secure:FALSE comment:@\"(null)\" commentURL:@\"(null)\" portList:[]>
<NSHTTPCookie version:0 name:@\"JSESSIONID\" value:@\"A variable number\" expiresDate:@\"(null)\" created:@\"301196866.000000\" sessionOnly:TRUE domain:@\"The Same URL as above\" path:@\"/path\" secure:FALSE comment:@\"(null)\" commentURL:@\"(null)\" portList:[]>
Now when I ask for the cookies based on the URL in the above cookies, first one gets returned, second one doesn't.
*note sorry about having to remove certain items, they are as expected and are not relevant for the question
I had that problem, the reason is because the NSHTTPCookieDomain. the cookies must have the same Domain
.... domain:@\"THE URL\" path:@\"/\" ....
.... domain:@\"The Same URL as above\" path:@\"/path\" ....
must be
.... domain:@\"NAME-DOMAIN" path:@"/" ....
i just change that, and put the same Domain and path and works
My JSESSIONID:
<NSHTTPCookie version:0 name:"JSESSIONID" value:"7C9B0...........EB5" expiresDate:(null) created:2012-07-06 16:14:26 +0000 (3.63284e+08) sessionOnly:TRUE domain:"FOO" path:"/" isSecure:FALSE>