How do YouTube and Google access each other's cookies?

Many stackoverflow studies have informed me that it’s not possible to get / set cookies from other domains.

but I see youtube.com doing this with google.com enter image description here

How do they do it?

+6
source share
2 answers

Your first statement is true - it is impossible to get / set cookies from other domains.

This cookie list shows what was set when viewing the page, but you must remember that the page includes resources from different places (images and scripts). When a script or image is pulled from another server, it has the ability to set a cookie. Despite the fact that the page on youtube.com caused all these cookies to be set, it only has access to the cookies on your youtube.com website.

+1
source

It uses google accounts to log in a user who needs to visit the google.com domain to authenticate the login, which then downloads the cookie. This cookie will not be sent to youtube.com, only google.com for login and authentication. The list that appears in Google Chrome lists all the cookies loaded for the entire request, it is not limited to the domain of the site you are viewing, and since youtube.com downloads files from other domains, it also extracts cookies from them. Well .

+1
source

Source: https://habr.com/ru/post/988497/


All Articles