What are the implications of the same origin policy in relation to tracking and cookies in PHP websites?

The same origin policy restricts how a website can interact with resources from a different origin, preventing the tracking of users across different domains. To overcome this limitation and allow cookies to be shared between subdomains, the 'SameSite' attribute can be set to 'None' and 'Secure' to enable cross-origin sharing.

// Set cookie with SameSite attribute to None and Secure
setcookie('cookie_name', 'cookie_value', [
    'expires' => time() + 3600,
    'path' => '/',
    'domain' => '.example.com',
    'secure' => true,
    'httponly' => true,
    'samesite' => 'None'
]);