How can session IDs be securely passed in PHP to ensure compatibility with different browsers?

Session IDs can be securely passed in PHP by using cookies with the "HttpOnly" and "Secure" flags set. This ensures that the session ID is only accessible by the server and not by JavaScript, and it is transmitted over secure HTTPS connections only. This approach helps prevent session hijacking and improves the overall security of the application.

// Set session cookie parameters with HttpOnly and Secure flags
session_set_cookie_params([
    'httponly' => true,
    'secure' => true
]);

// Start the session
session_start();