I set cookie a file of domain1.com with this method:
<script>
var dominio = '<?php echo "{$_SERVER['SERVER_NAME']}"; ?>';
document.cookie = 'dominio=' +dominio+'; expires=Wed, 1 Jan 2070 13:47:11 UTC; path=/; domain=domain2.com';
</script>
and get cookie from a file of domain2.com with this method:
<script>
function getCookie(nome) {
var nome = nome + "=";
var cookies = document.cookie.split(';');
for(var i = 0; i < cookies.length; i++) {
var c = cookies[i].trim();
if (c.indexOf(nome) == 0)
return c.substring(nome.length, c.length);
}
}
var url = new String(getCookie('dominio'));
var url2= ("https://"+url+"/vpanel/vpanel.php");
window.location.replace(url2);
</script>
but not working. If I try to write and read the cookie from the same domain it works, on different domains instead of no. Why?