簡體   English   中英

xhr(ajax)請求不發送所有cookie(nodeJS)

[英]xhr (ajax) request NOT sending all cookies (nodeJS)

使用nodeJS,我可以成功設置cookie。

在此處輸入圖片說明

當我呼叫頁面時,我正在發出2個請求。

DOM加載后,一個用於初始頁面和一個ajax請求

http://domain.com/pages/blog

http://domain.com/dataRequest

我的cookie出現在節點服務器上的初始請求中

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

但不在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

注意:由於某種原因,shopify設置了重復的cookie。 這些重復的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);
    }

我想到了。

Cookie正在將其自身設置為特定頁面/博客的路徑

固定:

{'set-cookie':'b_switch_session_id=lsd34JF3krK; path=/'}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM