What is the best practice for passing a session ID in a normal HTML link using PHP?

When passing a session ID in a normal HTML link using PHP, it is important to ensure the session ID is secure and not easily accessible to malicious users. One common way to achieve this is by using session_regenerate_id() to generate a new session ID before passing it in the link.

<?php
session_start();
session_regenerate_id();

$session_id = session_id();
echo '<a href="example.php?sid=' . $session_id . '">Click here</a>';
?>