If you are setting the session variable to 1 on the checkout page then you can use this code for the go to page:
if(!session_id()) session_start();
$GoToPage = (isset($_SESSION['checkout']) && $_SESSION['checkout'] ==1)?"checkout.php":"users_ThankYou.php";