Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
202 views
in Technique[技术] by (71.8m points)

Javascript get cookie from iframe

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...