All cookies are no sending for subdomain

Viewed 17

I'm trying to make an API call from one domain to another subdomain, I'm using jquery ajax for that, My problem is some cookies are sending while some are not sending. I want all the cookies to send. If I'm consoling document.cookie before sending the request in

                    var cookie = document.cookie;
                    console.info( "adding cookie:                        "+ cookie );          
                    xhr.setRequestHeader('Cookie', cookie);
                  },

It is printing all the cookies but some how in a request all the cookies are not sending.

        try {
            window.$.ajax({
                url: requestUrl,
                method: 'GET',
                contentType: 'text/plain',
                dataType: 'jsonp',
                jsonpCallback: 'callbackFnc',
                // headers: { 'Cookie': document.cookie },
                crossDomain: true,
                 // beforeSend : function(xhr) {  
                //     var cookie = document.cookie;
                //     console.info( "adding cookie:                        "+ cookie );          
                //     xhr.setRequestHeader('Cookie', cookie);
                //   },
                xhrFields: {
                    withCredentials: true
                },

                timeout: 5000,
                error: (xhr) => {
                    if (xhr && xhr.status === 200) {
                        resolve(true);
                    } else {
                        resolve(false);
                    }
                },
                success: (data, status, xhr) => {
                    if (xhr && xhr.status === 200) {
                        resolve(true);
                    } else {
                        resolve(false);
                    }
                }
            });
        } catch (err) {
            resolve(false);
        }

Request header : -

Cache-Control: no-cache
Connection: keep-alive
Cookie: abc=xy;
0 Answers
Related