Authorization on the site on the site mirror

Good afternoon. Is it possible to simultaneously authorize on the main domain and its mirror?
If so, how? It is desirable to work with cookies, rather than with sessions. But as I understand it, cookies are written only for one domain.


Answer 1, authority 100%

Copy the Yandex solution

At Yandex, all login forms lead to one point (passport.yandex.ru) and pass the return URL along with the login and password. The passport crawls into the database, checks the validity of the password and, if everything is OK, then for a short time shows the user a page with invisible pictures that are loaded from all domains where authorization is needed. everything is very tricky in terms of security, tokens and all that, but these are details. in short, the user’s browser sends requests for these pictures, and these requests are actually authorized. after all the pictures have loaded, the user will be redirected back to where he came from. not very elegant, for my taste, scheme, but, apparently, there is no better one.


Answer 2

You can make it an iframe, i.e. for example, on site1.ru, when the user clicks on the login button, the user logs in, and an invisible iframe appears with authorization on site2.ru/auth.php?login=test&pass=7624or not an iframe, but simply read site2.ru/auth.php?login=test&pass=7624via file_get_contents, i.e.:

<?php
//.... ,    ,  
file_get_contents("http://site2.ru/auth.php?login=".$login."&pass=".$pass);
?>