0

I have a cookie generated from one domain as below using jquery post?

  $.ajax({
        url: _domainURL1 + '/domain1/auth/start',
        type: 'POST',
        dataType: 'text',
        cache: false,
        crossDomain: true,
        xhrFields: { withCredentials: true },
        data: $('#data').val(),
        success: function (data) {

        },
        error: function (xhr, ajaxOptions, thrownError) {
            alert(thrownError);
        }
        complete: getCookie
    });


    function getCookie() {
         if (document.cookie) {
                $('#cookie').val(document.cookie);
            }
    }

Is it possible to attach the #cookie generated above from domain1 in the below request?

var data = {
                Type: "test1",
                ID: "testid1"
            };

         $.post(_domainURL2 + '/domain2/senddata', data, function (result) {
                alert("complete");
            });
Jyina
  • 2,530
  • 9
  • 42
  • 80
  • I'm not really sure what is being asked. How is the cookie supposed to be used in the second request? And is this in the same top level document? – Andrew Allison May 15 '19 at 17:34
  • seems possible if CORS is enabled on second domain – Rohit Mittal May 15 '19 at 17:48
  • If it is possible, do you have an example of how to do this? Thank you. – Jyina May 15 '19 at 18:20
  • It's not possible, please go through the below link. [Share-a-cookie-between-two-websites](https://stackoverflow.com/questions/12370495/share-a-cookie-between-two-websites) – Atul Jain May 16 '19 at 06:23

0 Answers0