i dont see the 404 error occuring.
the guest form element is posting to the cart page, so this code needs to be on the cart.php page.
<?php
if (!session_id()) session_start();
if((isset($_GET['guest']) && $_GET['guest'] != "")) {
$_SESSION["UserID"] = "0";
}
?>