head 1.1; branch 1.1.1; access ; symbols ePerl_2_2_14:1.1.1.1 RSE:1.1.1; locks ; strict; comment @# @; 1.1 date 99.05.02.14.43.39; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 99.05.02.14.43.39; author rse; state Exp; branches ; next ; desc @@ 1.1 log @Initial revision @ text @ ## ## demo.cgipm -- ePerl demonstration webpage ## Copyright (c) 1996,1997 Ralf S. Engelschall, All Rights Reserved. ## use CGI qw(:standard); use CGI::Cookie; # the name and initial value of our counter cookie my $cnt_name = 'counter'; my $cnt_value = 0; # fetch possibly existing counter cookie provided by the browser my %cookies = fetch CGI::Cookie; $cnt_value = $cookies{$cnt_name}->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"; !>
@ 1.1.1.1 log @Import of ePerl 2.2.14 @ text @@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 =$cnt_value!> times now. This counter is stored in a cookie, so push your RELOAD button a few times to see the effect.