9
我對另一個服務API進行了AJAX調用,然後應該返回一個將在我的瀏覽器中設置的cookie,以允許我調用其餘的API調用。Set-Cookie header未在Chrome中設置Cookie
但是,雖然響應頭包含一個'Set-Cookie'頭,但實際上沒有設置Cookie。我正在使用Google Chrome。
這裏是響應頭:
Access-Control-Allow-Origin:*
Cache-Control:no-cache
Connection:keep-alive
Content-Encoding:gzip
Content-Length:37
Content-Type:application/json
Date:Thu, 25 Jun 2015 18:27:37 GMT
Expires:Thu, 25 Jun 2015 18:27:36 GMT
Server:nginx/1.4.6 (Ubuntu)
Set-Cookie:sessionid=67cb9796aa794a4975b28876ea6dd3d5; expires=Thu, 09-Jul-2015 18:27:37 GMT; httponly; Max-Age=1209600; Path=/
Vary:Cookie
這裏是AJAX調用:
$.ajax({
type: "POST",
crossDomain: true,
contentType: 'text/plain',
data: data,
url: urlhere
success: function(result, status, xhr){
console.log('hi');
console.log(xhr.getAllResponseHeaders());
},
error: function(xhr){
console.log(xhr.status);
console.log(xhr.statusText);
}
});
的鉻資源頁面還顯示,沒有任何cookie被設定。任何和所有的幫助將不勝感激!
你看了這裏:http://stackoverflow.com/questions/16019135/set-cookie-without-page-refresh – testing123