<?php
    # this block must be used before HTML code because it generates
    # or accessess HHTP header and inspect or/and generate cookies.

    # if the cookie was set before its value is already 
    # available in the variable $_COOKIE['...........']

    # alternatively you can set the PHP driective:
    # register_globals = on
    # and use the given variable directly
    # i.e. as $clientside_count



if ( isset ($_COOKIE['clientside_count']) ) {
    $_COOKIE['clientside_count']++;
} else {
    $_COOKIE['clientside_count']=1;
}

    # now it needs to be transmitted back 
    # to the client with the Web page header
setcookie("clientside_count", $_COOKIE['clientside_count'], time()+60);
    # if you want to save cookies between sessions
    # you need to set the expiration date and path
    # expiration is in seconds
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
<title>PHP Example</title>
</head>
<body>
<?php
    echo $_COOKIE['clientside_count'],"\n";
?>
</body>
</html>