How can PHP developers ensure the security of passing Session-IDs in URLs, particularly in the context of mod_rewrite usage?

To ensure the security of passing Session-IDs in URLs, particularly in the context of mod_rewrite usage, PHP developers should use session cookies instead of passing Session-IDs in URLs. This helps prevent Session-IDs from being exposed in the browser's address bar or in server logs, reducing the risk of session hijacking attacks.

// Start a secure session
session_start([
    'cookie_secure' => true,
    'cookie_httponly' => true
]);