How can the use of the PHP constant "SID" help in maintaining session continuity when cookies are blocked or not set properly?

When cookies are blocked or not set properly, session continuity can be maintained by using the PHP constant "SID" to append the session ID to URLs. This allows the session to be passed between pages even if cookies are not available.

<?php
session_start();

if(isset($_SESSION['username'])) {
    echo 'Welcome back, ' . $_SESSION['username'];
} else {
    $_SESSION['username'] = 'JohnDoe';
}

echo '<a href="page2.php?' . SID . '">Go to Page 2</a>';
?>