Are there any security concerns to consider when passing session IDs through URLs in PHP websites?

Passing session IDs through URLs in PHP websites can pose security concerns as they can be easily intercepted or shared. To mitigate this risk, it is recommended to use cookies to store session IDs instead of passing them through URLs. This helps prevent session hijacking and unauthorized access to user sessions.

// Start session
session_start();

// Set session ID in a cookie
$session_id = session_id();
setcookie('session_id', $session_id, time() + 3600, '/', '', false, true);