We are developing an application to run as iframe in another web site. The iframe will set cookies on the server side at some point, the javascript will be triggered to get the cookies and display the messages on the page for the users. The page runs well on its own host. It also works well when it's running as an iframe in a website with the same domain (iframe: xxx.a.org, parent site: yyy.a.org). But the javascript has problem to get the cookies when it's running as iframe in a website with different domain (iframe: xxx.a.org, parent site: yyy.b.edu).
The iframe is developed with Spring+Java+jsp.
The javascript code is on the same server as the iframe is. Aren't the javascript and cookies in the same domain when parent site is yyy.b.edu and iframe domain is xxx.a.org? Why the javascript cannot get the cookies set by the iframe? In this case, what is the domain for the cookies set by the iframe?
How can I solve this problem?
Thanks a lot for any suggestions!
question from:
https://stackoverflow.com/questions/65949819/javascript-get-cookie-from-iframe 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…