Link to home
Start Free TrialLog in
Avatar of deeayrian
deeayrianFlag for United States of America

asked on

Cannot get cookie counter to increment

My assignment requires that I show how many times a user has visited the site by using a cookie to count in Perl.  Although cookies are very simple, for some reason, I can not get my cookie to count past 1.  I have compared my information to online sources and it all looks correct, but not matter what it doesn't work.  Please view my code below.  Thank you!
#retreive count cookie
$count = cookie('Count');
 
$count++; (there are two plus signs here but for some reason the preview isn't showing them)
 
#there is a name cookie created here as well
$C_count = cookie(-name => "Count",
                               -value => "$count",
                               -expires => "+6M");
 
print header(-cookie => $C_name, $C_count);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of oleber
oleber
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of deeayrian

ASKER

Ah ha!  Thank you so much!  I actually need that other cookie in there to be printed (it is a different part of the code) but because you pointed out that portion of the code, when I removed the name cookie, it worked.  Then I realized that I had the code wrong for sending more than one cookie to the browser.  To send more than one cookie to the browser, the code is:  
print header(-cookie => [$C_name, $C_count]);

Thank you!