I'm developing a PhoneGap app in Xcode that communicates with a server using a web api. The api accepts standard http requests. As part of the user authentication process a cookie is set that is supposed to be transmitted in the http header with each subsequent request to the api.
During the login call to the api, I can clearly see that a cookie is being sent back as part of the response header. However, it doesn't seem to get stored, nor does it get sent in the http request header with each new api call.
To make calls to the api, I'm using jQuery's $.getJSON
call.
I found the following question and answer: phonegap: cookie based authentication (PHP) not working [webview]
The above answer suggests setting the NSHTTPCookieStorage cookieAcceptPolicy
to NSHTTPCookieAcceptPolicyAlways
in the app delegate's init
. I have tried that and it doesn't seem to solve the issue. Also, according to Apple's documentation, the default cookieAcceptPolicy
is NSHTTPCookieAcceptPolicyAlways
.
Suggestions on how to get cookie storage and sending working are highly appreciated.