php - Passing cookie data between iframes - Stack Overflow

Say I have a website, www.example, with a login box which sits in an iframe situated in api.example. My

Say I have a website, www.example, with a login box which sits in an iframe situated in api.example. My question is:

  1. Is it possible to pass cookie data from the inner iframe (api.example to the website, so the website knows when the user logged in?
  2. Is it possible to do this client-side, without the need to refresh the whole page? How would the fact that user logged in be passed to the website?

Any solution which works on FF and IE 6/7 would be great.

Say I have a website, www.example., with a login box which sits in an iframe situated in api.example.. My question is:

  1. Is it possible to pass cookie data from the inner iframe (api.example. to the website, so the website knows when the user logged in?
  2. Is it possible to do this client-side, without the need to refresh the whole page? How would the fact that user logged in be passed to the website?

Any solution which works on FF and IE 6/7 would be great.

Share Improve this question edited Jan 18, 2009 at 9:19 user49226 asked Jan 18, 2009 at 8:22 user49226user49226 1512 gold badges4 silver badges8 bronze badges 1
  • Please add tag for your serverside platform – AnthonyWJones Commented Jan 18, 2009 at 8:37
Add a ment  | 

2 Answers 2

Reset to default 4

You don't have to pass the cookie between them. You need to write the cookie to the right domain though.

Response.Cookies("COOKIENAME").Domain = ".example."
Response.Cookies("COOKIENAME").Value= "foo"

A cookie can be shared between two domains like api.example. and www.example. by having the server specify the cookie domain to be simply example.. This makes the cookie available to both sub-domains.

FF3 and IE8 support then postMessage standard which allow windows(frames) in different domains to talk to each other. However for IE6/7 you would need an AJAX call to the server to get what ever login confirmation you need but tricky thing would be knowing how to trigger such a request.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745283757a4620435.html

相关推荐

  • php - Passing cookie data between iframes - Stack Overflow

    Say I have a website, www.example, with a login box which sits in an iframe situated in api.example. My

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信