小编Mat*_*ttA的帖子

Set-Cookie标头未在Chrome中设置Cookie

我是AJAXing调用另一个服务API,然后应该返回一个cookie,该cookie将在我的浏览器中设置,以允许我进行其余的API调用.

但是,虽然响应头包含"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
Run Code Online (Sandbox Code Playgroud)

这是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);
            }
});
Run Code Online (Sandbox Code Playgroud)

Chrome资源页面还显示没有设置Cookie.任何和所有的帮助将不胜感激!

javascript cookies ajax jquery google-chrome

13
推荐指数
1
解决办法
9598
查看次数

标签 统计

ajax ×1

cookies ×1

google-chrome ×1

javascript ×1

jquery ×1