What are the potential issues when using setcookie in PHP, especially when transitioning between different PHP versions?

Potential issues when using setcookie in PHP, especially when transitioning between different PHP versions, include changes in default settings like the SameSite attribute for cookies, which can lead to unexpected behavior in newer PHP versions. To ensure compatibility, explicitly set all necessary cookie parameters when using setcookie, including the SameSite attribute.

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