How can cookies impact session handling in PHP?

Cookies can impact session handling in PHP by potentially exposing sensitive session data if not handled properly. To mitigate this risk, it is important to set the session cookie parameters securely, such as setting the 'secure' flag to true to only send the cookie over HTTPS connections and using the 'HttpOnly' flag to prevent client-side scripts from accessing the cookie.

// Set session cookie parameters securely
session_set_cookie_params([
    'lifetime' => 0,
    'path' => '/',
    'domain' => 'example.com',
    'secure' => true,
    'httponly' => true
]);

// Start the session
session_start();