value if ($cookies{$cnt_name}); # increase the value, because its an access counter $cnt_value++; # create the new counter cookie and send it back to the browser my ($myname, $mypath) = ($ENV{'SCRIPT_SRC_URL'} =~ m%^http://(.+?)(?:|:\d+)(/.*)$%); my $cookie = new CGI::Cookie( -name => $cnt_name, -value => sprintf("%d", $cnt_value), -domain => $myname, -path => $mypath, -expires => '+24h' ); print "Set-Cookie: $cookie\n"; !> demo.cgipm

demo.cgipm

High-level HTTP programming with CGI.pm

This demonstrates how one can create complex HTTP headers like Netscape Cookies by programming them via Perl's CGI::Cookie module.

You have accessed this demo times now. This counter is stored in a cookie, so push your RELOAD button a few times to see the effect.