What are the potential risks or security concerns when using session IDs in URLs?

When using session IDs in URLs, there is a risk of exposing sensitive information to third parties, such as in shared links or browser history. This can lead to session hijacking or unauthorized access to user accounts. To mitigate this risk, it is recommended to use cookies to store session IDs instead of including them in URLs.

// Use cookies to store session ID instead of including it in URLs
session_start();
$session_id = session_id();
setcookie('session_id', $session_id, time() + 3600, '/', '', false, true);