简体   繁体   中英

How Facebook reads cookies from other domains

I searched a lot about "how to read cookies from other domains" but I always have the same answer.

suppose we have two different domains. dom1.com & dom2.com what I want is to read a cookie from dom2.com while I'm in the first domain.

When I searched for that I found that it's impossible to do that if you don't own the two domains even if you make iFrame for dom2.com in the first domain.

But then I wondered. Facebook does that. You can comment, make likes and deal with Facebook's applications in other domains than Facebook.

So how does it work? And what is the code for that?

It is not reading cookies from other doamins, is a mix of using CORS to access api.facebook.com and embedded IFRAMES. I cannot tell exactly how it works currently, but basically the API can tell you how many likes something has, and when opening an IFRAME to facebook.com, you are sending your Facebook credentials, but that does not mean that those credentials are accessed by the container page, it is just like running a small browser inside the page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM