How do I set a cookie for an iframe with a different domain?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I need to construct a page that contains an iframe that in turn shows a page from an AWS service. Constructing a parent page that contains such an iframe is no problem. I need to access the DOM of the AWS page from the parent page but the Same Domain Policy prevents me from doing this so I have had to write code to serve as a proxy that fetches and returns the page HTML of the AWS service. So, my server returns the parent page which contains an iframe that in turn requests another page from my server which is the AWS service page HTML. Since the I-frame HTML is from the same Domain as the parent page the parent should be able to access the I-frame Dom.



The problem I am having is that the AWS service page requires cookies. When the parent page iframe requests the AWS service page HTML from my server I am unable to return the cookies with a domain that points to AWS. If I return the HTML with cookies where no domain is specified the cookies are created in the browser but they are associated with my server's domain and that won't work. If I set the cookies domain to be the AWS domain the cookies fail to be created. In both the Firefox and Chrome debugger I examine network traffic and see that the cookies are being transmitted to the browser but if the domain is for AWS the cookies are not created.



Research shows that this is a known issue that is related to the Same Domain Policy. If I understand correctly what I'm trying to do is set 3rd party cookie so I have (at least for testing purposes) made sure that both the Firefox and Chrome browsers allow third-party cookies but this still fails. The only suggestions that I have found for how to deal with this require that I have control over both servers and of course I have no access to the AWS servers.



How can I create these cookies so that the iframes AWS service page can access them?



Thank you.










share|improve this question





























    0















    I need to construct a page that contains an iframe that in turn shows a page from an AWS service. Constructing a parent page that contains such an iframe is no problem. I need to access the DOM of the AWS page from the parent page but the Same Domain Policy prevents me from doing this so I have had to write code to serve as a proxy that fetches and returns the page HTML of the AWS service. So, my server returns the parent page which contains an iframe that in turn requests another page from my server which is the AWS service page HTML. Since the I-frame HTML is from the same Domain as the parent page the parent should be able to access the I-frame Dom.



    The problem I am having is that the AWS service page requires cookies. When the parent page iframe requests the AWS service page HTML from my server I am unable to return the cookies with a domain that points to AWS. If I return the HTML with cookies where no domain is specified the cookies are created in the browser but they are associated with my server's domain and that won't work. If I set the cookies domain to be the AWS domain the cookies fail to be created. In both the Firefox and Chrome debugger I examine network traffic and see that the cookies are being transmitted to the browser but if the domain is for AWS the cookies are not created.



    Research shows that this is a known issue that is related to the Same Domain Policy. If I understand correctly what I'm trying to do is set 3rd party cookie so I have (at least for testing purposes) made sure that both the Firefox and Chrome browsers allow third-party cookies but this still fails. The only suggestions that I have found for how to deal with this require that I have control over both servers and of course I have no access to the AWS servers.



    How can I create these cookies so that the iframes AWS service page can access them?



    Thank you.










    share|improve this question

























      0












      0








      0








      I need to construct a page that contains an iframe that in turn shows a page from an AWS service. Constructing a parent page that contains such an iframe is no problem. I need to access the DOM of the AWS page from the parent page but the Same Domain Policy prevents me from doing this so I have had to write code to serve as a proxy that fetches and returns the page HTML of the AWS service. So, my server returns the parent page which contains an iframe that in turn requests another page from my server which is the AWS service page HTML. Since the I-frame HTML is from the same Domain as the parent page the parent should be able to access the I-frame Dom.



      The problem I am having is that the AWS service page requires cookies. When the parent page iframe requests the AWS service page HTML from my server I am unable to return the cookies with a domain that points to AWS. If I return the HTML with cookies where no domain is specified the cookies are created in the browser but they are associated with my server's domain and that won't work. If I set the cookies domain to be the AWS domain the cookies fail to be created. In both the Firefox and Chrome debugger I examine network traffic and see that the cookies are being transmitted to the browser but if the domain is for AWS the cookies are not created.



      Research shows that this is a known issue that is related to the Same Domain Policy. If I understand correctly what I'm trying to do is set 3rd party cookie so I have (at least for testing purposes) made sure that both the Firefox and Chrome browsers allow third-party cookies but this still fails. The only suggestions that I have found for how to deal with this require that I have control over both servers and of course I have no access to the AWS servers.



      How can I create these cookies so that the iframes AWS service page can access them?



      Thank you.










      share|improve this question














      I need to construct a page that contains an iframe that in turn shows a page from an AWS service. Constructing a parent page that contains such an iframe is no problem. I need to access the DOM of the AWS page from the parent page but the Same Domain Policy prevents me from doing this so I have had to write code to serve as a proxy that fetches and returns the page HTML of the AWS service. So, my server returns the parent page which contains an iframe that in turn requests another page from my server which is the AWS service page HTML. Since the I-frame HTML is from the same Domain as the parent page the parent should be able to access the I-frame Dom.



      The problem I am having is that the AWS service page requires cookies. When the parent page iframe requests the AWS service page HTML from my server I am unable to return the cookies with a domain that points to AWS. If I return the HTML with cookies where no domain is specified the cookies are created in the browser but they are associated with my server's domain and that won't work. If I set the cookies domain to be the AWS domain the cookies fail to be created. In both the Firefox and Chrome debugger I examine network traffic and see that the cookies are being transmitted to the browser but if the domain is for AWS the cookies are not created.



      Research shows that this is a known issue that is related to the Same Domain Policy. If I understand correctly what I'm trying to do is set 3rd party cookie so I have (at least for testing purposes) made sure that both the Firefox and Chrome browsers allow third-party cookies but this still fails. The only suggestions that I have found for how to deal with this require that I have control over both servers and of course I have no access to the AWS servers.



      How can I create these cookies so that the iframes AWS service page can access them?



      Thank you.







      java cookies iframe cross-domain same-origin-policy






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 3 at 22:40









      Al KochAl Koch

      1541516




      1541516
























          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54030793%2fhow-do-i-set-a-cookie-for-an-iframe-with-a-different-domain%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54030793%2fhow-do-i-set-a-cookie-for-an-iframe-with-a-different-domain%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Monofisismo

          Angular Downloading a file using contenturl with Basic Authentication

          Olmecas