How does the use of cookies impact the passing of Session IDs in PHP?

When using cookies to store session IDs in PHP, it is important to ensure the cookies are secure and cannot be easily tampered with by users. To address this issue, it is recommended to use the 'httponly' and 'secure' flags when setting the cookie to prevent potential security vulnerabilities.

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