[英]xhr (ajax) request NOT sending all cookies (nodeJS)
With nodeJS i am successfully setting a cookie. 使用nodeJS,我可以成功设置cookie。
When i call a page, I am making 2 requests. 当我呼叫页面时,我正在发出2个请求。
One for the initial page and an ajax request once the DOM has loaded DOM加载后,一个用于初始页面和一个ajax请求
http://domain.com/pages/blog http://domain.com/pages/blog
http://domain.com/dataRequest http://domain.com/dataRequest
My cookie appears in the initial request on the node server 我的cookie出现在节点服务器上的初始请求中
http://domain.com/pages/blog http://domain.com/pages/blog
b_switch_session_id=3442047e6f50effc9108709bae089aa4;
_shopify_y=F8DD2A56-4D75-4478-ACF4;
_shopify_y=F8DD2A56-4D75-4478-ACF4;
ajs_anonymous_id=%2258922eb3-abd1-44a6-a35b-4dbe00bf62ba%22;
_session_id=40ac642b90ec66f0da1b0f6af9176f7d;
_shopify_visit=t;
_shopify_uniq=x;
_shopify_s=8B5A83C5-3B48-4EF7-816A;
_shopify_s=8B5A83C5-3B48-4EF7-816A;
ajs_group_id=null;
ajs_user_id=null;
_ga=GA1.2.1751239978.1452678921;
_gat=1
But not in the ajax request 但不在ajax请求中
ajs_anonymous_id=%2258922eb3-abd1-44a6-a35b-4dbe00bf62ba%22;
_session_id=40ac642b90ec66f0da1b0f6af9176f7d;
_shopify_y=F8DD2A56-4D75-4478-ACF4;
_ga=GA1.2.1751239978.1452678921;
_gat=1;
_shopify_visit=t;
_shopify_uniq=x;
_shopify_s=8B5A83C5-3B48-4EF7-816A;
ajs_group_id=null;
ajs_user_id=null
Note: For some reason shopify sets duplicate cookies. 注意:由于某种原因,shopify设置了重复的cookie。 These duplicate cookies appear in request.headers on node for the initial request, but the duplicates do note appear in node for the ajax request
这些重复的cookie出现在初始请求的节点上的request.headers中,但是重复的注释确实出现在ajax请求的节点中
function callAjax(Url)
{
//get domain name from url
var url = Url
var arr = url.split("/");
var domain = arr[0] + "//" + arr[2]
var ref = window.location.href;
//console.log(ref);
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function()
{
}
xmlhttp.open("GET", domain+"/dataRequest", true);
xmlhttp.send(ref);
}
I figured it out. 我想到了。
The cookie was setting its self for the path of the specific page /blog Cookie正在将其自身设置为特定页面/博客的路径
fix: 固定:
{'set-cookie':'b_switch_session_id=lsd34JF3krK; path=/'}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.