views:

93

answers:

1

Hi Guys,

I have a domain A.com [my website] and a remote website B.com which integrates an iframe from my domain [A.com] with a piece of javascript.

I want to share cookies across these domains [within the iframe]? How would I go about doing this so it works properly? I thought A.com and B.com are in the same-origin policy ?

A: 

How is a.com and b.com same origin? They are different domains. You can't share cookies that way. For example:

  • example.com
  • fritters.com

Can not share cookies even if fritters.com is in an iframe inside example.com.

  • fred.example.com
  • www.example.com

can share domain cookies because they are both the same domain (example.com) but have different subdomains, so you can assign the cookie to *.example.com.

Erik
thanks for the response. i thought the iframe and A.com were in the same-origin policy ? since the iframe is loading content from a.com?
Frederick
is it possible to then share cookies between something served FROM example.com inside an iframe on fritters.com ?
Frederick
No, its not. No matter what example.com cookies can only be accessed by javascript running on a page on example.com. It doesn't matter if fritters.com frames example.com's page, fritters.com NEVER gets access to example.com's cookies. Same origin policy means exactly that - the cookie is only available to the domain which originated it.
Erik
hey - i thought P3P policy would allow this exact type of thing to occur ?
Frederick

related questions