What are the recommended best practices for securely transmitting session IDs in PHP applications?

When transmitting session IDs in PHP applications, it is crucial to ensure that they are securely handled to prevent unauthorized access to user sessions. One recommended best practice is to always use HTTPS to encrypt the communication between the client and server, preventing session hijacking attacks. Additionally, it is important to store session IDs in secure HTTP cookies rather than passing them through URLs to avoid exposing them in the browser history or logs.

// Set session cookie parameters for secure transmission
session_set_cookie_params([
    'secure' => true, // Only transmit over HTTPS
    'httponly' => true, // Prevent access from JavaScript
    'samesite' => 'Strict' // Limit cross-site request forgery
]);

// Start the session
session_start();