Reputation: 604
i've a question about cookie and domains.
Suppose I drop a cookie to a user from domain www.firstdomain.com. Suppose the user visits another page under the domain: www.seconddomain.com. How can I access to my cookie previously set from this page? I know that access to a cookie with domain=firstdomain from a domain=seconddomain is not possible, but if I've the possibility to use an iframe on the page www.seconddomain.com and I load the iframe from www.firstdomain.com/something, then can I access to my cookie?
Thank in advance,
Alessio
Upvotes: 0
Views: 1833
Reputation: 1338
You are flying in the face of internet security and privacy - so while it is possible to do this today you need to anticipate some issues in the future.
It is possible to implement javascript handlers to set and get values from a cookie and the call from different iframes. This I expect is the safest route.
The iframe would have to consent by implementing helper functions to perform these tasks so things remain controlled.
The iFrame would have permission to read the cookie and then can communicate to the parent iframe using a call to the parent window.
An example is here: How to Call Parent Window JavaScript Function inside iframe
Upvotes: 1