Cross-Domain Cookies

后端 未结 15 2545
抹茶落季
抹茶落季 2020-11-21 21:56

I have two webapps WebApp1 and WebApp2 in two different domains.

  1. I am setting a cookie in WebApp1 in the HttpResponse.
  2. How to read the same cookie fro
15条回答
  •  长发绾君心
    2020-11-21 22:47

    Do what Google is doing. Create a PHP file that sets the cookie on all 3 domains. Then on the domain where the theme is going to set, create a HTML file that would load the PHP file that sets cookie on the other 2 domains. Example:

    
       
       
          

    Please wait.....

    Then add an onload callback on body tag. The document will only load when the images completely load that is when cookies are set on the other 2 domains. Onload Callback :

    
       
    
    
    
    setcookie.php
    

    We set the cookies on the other domains using a PHP file like this :

    
    

    Now cookies are set on the three domains.

提交回复
热议问题