Hey folks, having problem making a cookie recording number of visits to a website.
The $VISITS always remains 1, I can't figure it out. It should go to 1, and then update every time after.
PHP:
// cookies.php
// Program to write a cookie to a client's machine
extract( $_POST );
// write each form fields value to a cookie and set the
// cookies expiration date
setcookie( "Name", $NAME, time() + 60 * 60 * 24 * 5 );
setcookie( "Color", $COLOR, time() + 60 * 60 * 24 * 5 );
extract( $_COOKIE );
if($_COOKIE[Visits] > 0 ){
//also tried if(isset($VISITS)){
$VISITS = $VISITS + 1;
}
else{
$VISITS = 1;
}
setcookie( "Visits", $VISITS, time() + 60 * 60 * 24 * 5 );
The $VISITS always remains 1, I can't figure it out. It should go to 1, and then update every time after.
Last edited: