I am trying to set a cookie to track how manytimes a visitor has come to the site. I would like to set the cookie and work with it all on the same page. my code looks like the following:
my ($visits, $name, $C_visits, $msg);
#retrieve Name cookie
$visits = cookie('Visits');
$name = cookie('Name');
if ($visits < 0) {
$msg = "This is your first visit to our site!\n";
$visits = 1;
}
else {
$msg = "You have visited us $visits times.\n";
}
$visits++;
$C_visits = cookie(-name => "Visits",
-value => "$visits",
-expires => "+6M");
print header(-cookie => $C_visits);
It keeps giving me an error and have beat my head on the wall to try and figure it out. Please help.
my ($visits, $name, $C_visits, $msg);
#retrieve Name cookie
$visits = cookie('Visits');
$name = cookie('Name');
if ($visits < 0) {
$msg = "This is your first visit to our site!\n";
$visits = 1;
}
else {
$msg = "You have visited us $visits times.\n";
}
$visits++;
$C_visits = cookie(-name => "Visits",
-value => "$visits",
-expires => "+6M");
print header(-cookie => $C_visits);
It keeps giving me an error and have beat my head on the wall to try and figure it out. Please help.