How do I set cookies from outside domains inside iframes in Safari?

前端 未结 5 1679
梦毁少年i
梦毁少年i 2020-12-08 10:55

From the Apple developer faq

Safari ships with a conservative cookie policy which limits cookie writes to only the pages chosen (\"navigated to\

5条回答
  •  渐次进展
    2020-12-08 11:10

    This is an issue known as Same Origin Policy. Essentially it is a security measure against creating security loopholes.

    When you have an iframe that points to a page on your own domain, JavaScript can access both the page you're on and the page within the Iframe. This is an acceptable parent to child and child to parent relationship.

     (parent doc)        (iframe doc)
        HTML --> IFRAME <-- HTML 
          ^--------|---------^
    

    However, once you have a file pointing to an external page, SOP comes into play and haults any information passing between the parent page and the iframe page.

     (parent doc)        (iframe doc)
        HTML --> IFRAME <-- HTML 
                   X
    

    Check out this post about iframe communication, it makes a lot of sense! Stackoverflow post

    These links really help too!

    1) Secure Cross-Domain Communication in the Browser
    2) wiki SOP or Same Origin Policy

    Good luck!

提交回复
热议问题