NSURLSession single sign on cookie missing in Watchkit2

we encountered a strange problem when using NSURLSession with watchkit 2, ios 9.0.

most headers and cookies are returned from the server (using HTTPS)

but the single sign on cookie is missing

when running the exact same code in an iphone application (request via NSURLSession) the cookie is visible in the shared cookie storage.

I've read alot of posts on how to add headers via the HTTPAdditionalHeaders, but this specific cookie should have been returned from the server

why would one specific cookie go missing while the others are returned?

We found the problem. This specific cookie was added in a redirect.

When running via Watchkit, the header did not include the set-cookie header, even thought the additional cookie was returned in the response.

Again - the strange thing was that this works perfect when running via iphone app and widget.

Could it be that via watch the request is running in a 'background' mode (similar to an app in the background) hence the difference? I've read that there's a know bug when running NSURLSession requests when the app is in the background but I'm not really sure of the nature of the bug.


Any comments would be great.

I have the same issue. Cookie is not visible when requsting with NSURLSession with Watch Kit 2.

fwiw I'm still running into this problem today with watchOS 9.1. HTTPCookieStorage.shared.cookies only appears to get set on non-redirected requests. This makes multi-redirect login/auth flows fail, because the cookie handshakes don't occur across redirects.

NSURLSession single sign on cookie missing in Watchkit2
 
 
Q