views:

90

answers:

1

Hi everyone,

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

A: 

Please break down your problem in pieces, first check if

[[NSHTTPCookieStorage sharedHTTPCookieStorage]
    cookiesForURL:[NSURL URLWithString:theCookie]]

returns what you think it should return. If not, take a closer look at the value of theCookie.

mvds
I have and I've tested what I get through the web browser compared to what I get through the iPhone App and its what is expected except for the JSESSIONID's. I use NSURLConnection to retrieve content from a few different websites. Each one I check I don't get any JSESSIONID's whereas I do through the web browser
Rudiger
this is getting a little vague, can you provide a code snippet and a trace showing what you see? E.g. the full cookiejar and the filtered cookiesForUrl, including the URL. So we can all see the oddness, and might explain or at least reproduce it.
mvds
Updated, no closer to figuring out.
Rudiger