Re: How to get two cookies back from jquery getResponseHeader('Set-Cookie') for Android

3,279 views
Skip to first unread message

Eduardo Sartori de Camargo

unread,
Nov 10, 2013, 3:03:03 PM11/10/13
to phon...@googlegroups.com
Hi! Do you have any answer? I am also stuck in this point.

Thank you!

Em segunda-feira, 18 de fevereiro de 2013 22h05min11s UTC-3, Maggie Yu escreveu:

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);
    }  
});

betrob

unread,
Nov 20, 2013, 5:05:02 AM11/20/13
to phon...@googlegroups.com
Hi Maggie,

I have the same issue too. I only get back one cookie even though there are many cookies that I can see on the browser. And another wierd thing is that I get the Set-Cookie header only after the first time the application is installed, from the second request onwards the Set-Cookies header returns null.

Can you please explain why this is happening .... Were you able to resolve the issue ????

Thanks in advance.
Reply all
Reply to author
Forward
0 new messages