What potential issues can arise when setting cookies with different top-level domains?

When setting cookies with different top-level domains, potential issues can arise due to the SameSite attribute restrictions. To solve this issue, you can set the SameSite attribute to None and also include the Secure attribute to ensure the cookie is sent over secure connections only.

setcookie('cookie_name', 'cookie_value', [
    'expires' => time() + 3600,
    'path' => '/',
    'domain' => '.example.com',
    'samesite' => 'None',
    'secure' => true
]);