试图读取某人的代码重新编写cookie

I am trying to read some code here (not my own) and make changes. So far what I can get from reading it is that if a variable named $cuid is NOT set, it sends a user to a splash page. If it IS set, it sets the cookie to the $cuid variable (which is actually not happening, the cookie isn't updated when you come with a new CUID in GET)

Here's the code:

if (!$cuid || $reset)
{
    $cuid="";

    if( $cuid_demo!="samplecu" && $cuid!="75541953" )
        setcookie("cuid","",time() - 31536000); //DELETES COOKIE

    $query="UPDATE cusucceed SET kkc_visits=kkc_visits+1 WHERE id = '$cuid'";
    $result=dbquery($link, $query) or die("error: ".dberror() );
    include("splash.php");
}
else
{
    setcookie("cuid","",time() - 31536000); //DELETES COOKIE
setcookie("cuid",$cuid,time()+604800); //1 week.
    select_db($link) or die("error: ".dberror() );

    if($admin_id)
    {
        $cuid=$cuid;
        $id=$cuid;
    }

    $query="UPDATE cusucceed SET kkc_visits=kkc_visits+1 WHERE id = '$cuid'";
    $result=dbquery($link, $query)or die("Database Server Error 2");
    include("index_main.php");

Am I reading that correctly? The else part of the if statement should be setting the cuid cookie to $cuid, if $cuid is set, yes?

If $cuid is unassigned (more explicity, has a false result [albeit 0, false, empty]) or it should be $reset,
- Force-empty the cookie (assuming it's not [what appears to be] a test account)
- Display the splash page.

If $cuid is set (and it's not a $reset),
- Re-declare the cuid cookie, and make it last for a week. Then also display the main page.

In both instances,
- Increment the number of times the found $cuid has visited the page.

Although to be honest, it looks like the author wasn't really sure what they were doing based on duplicated code and that they feel the need to empty a cookie before re-declaring it.