Accessing cross-domain intranet cookies

74 views Asked by At

I own 2 domains, A and B, hosted with web applications. From an application in domain A, I call a service in B, which takes some time. So I show a loading GIF.

In the service in B, I set a cookie along with the response in Java:

HttpResponse resp;        
Cookie fileDownloadStatus = new Cookie("fileDownload", "true");
fileDownloadStatus.setPath ("/App");
fileDownloadStatus.setDomain("x.x.x.x");
resp.addCookie(fileDownloadStatus);

In A, I keep looking for the cookie, so I can stop the loading GIF, but I am unable to get the cookie in JavaScript, even though I tried setting the path of the cookie and the domain for the cookie as if it were sent from A:

var fileDownloadCheckTimer;
fileDownloadCheckTimer = window.setInterval(function () {
    var cookies = document.cookie;
    console.log(cookies);
    var cookieArray = cookies.split(';');
    console.log(cookieArray);
    for(var i=0;i<cookieArray.length;i++)
    {
        var reqCookie = cookieArray[i].split('=');
        console.log(reqCookie);
        if(reqCookie[0]=="fileDownload")
        {
            if(reqCookie[1] == "true")
                finishDownload();
        }
    }
}, 1000);

Please assist.

0

There are 0 answers