ajax获取set-cookie,javascript - Ajax Set-Cookie Header Response - Stack Overflow

I have a project which using a a REST API. Here when I send a login request, they are sending me the response as JSON containg some data. Along with that in Response Header

Access-Control-Allow-Origin:*

Cache-Control:private

Content-Encoding:gzip

Content-Length:49

Date:Sun, 28 Jul 2013 08:09:29 GMT

ntCoent-Length:36

Server:Apache-Coyote/1.1

Set-Cookie:JSESSIONID=044F94AFE2997F02475315474E3B822D; Path=/

Set-Cookie:NSC_Ibgja-IUUQt=ffffffffc3a0b60545525d5f4f58455e445a4a4229a0;expires=Sun, 28-Jul-2013 08:55:40 GMT;path=/;secure

X-Powered-By:Servlet 2.4; JBoss-4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA

Here we have a Set-Cookie , but this cookie is not setting. I need this cookie to be setted, because for any other API access, the server will check for this cookie.

How can I resolve this Issue? What is the solution for jQuery AJAX response Header Set-Cookie method?

Update:

the first ajax for login

var json='{"nin":"'+1080258278+'","password":"'+840622+'"}';

var hostURL = "https://www.hafiz.gov.sa";

$.ajax({

type: "POST",

url: hostURL + "/HRDFWeb/AuthenticateDirectly",

data: "json="+json+"&date="+Number(new Date()),

dataType: "json",

timeout: 180000, // in milliseconds

success: function(data, textStatus, XMLHttpRequest){

console.log(data);

},

error: function(request, status, err) {

}

});

你可能感兴趣的:(ajax获取set-cookie,javascript - Ajax Set-Cookie Header Response - Stack Overflow)