I am implementing an Android app that sends requests to a web server using PhoneGap. Before sending other requests, the app first has to send an authentication request to the web server, and the response returns two pairs of cookies (one for SSL, and one for session ID) in the response header.
I send an ajax request and access the cookies in the success callback via jqXHR object. I try with getResponseHeader('Set-Cookie') and getAllResponseHeaders(). Both methods return only the first pair of cookies. How do I get two pairs of cookies back from an ajax request?
Here is my code:
$.ajax({ url: "https://webservice.com/Android.asmx/authenticate", type: "POST", dataType: "json", contentType: "application/json; charset=utf-8", data: JSON.stringify(textJson), success: function(result, textStatus, jqXHR){ var cookies = jqXHR.getResponseHeader('Set-Cookie'); console.log(cookies); }, error: function(result){ console.log("Failed"); console.log(result); } });