$ cat cgiapp.pl #!/usr/local/bin/perl use warnings; use strict; TestApp->new->run; package TestApp; use base qw|CGI::Application|; use CGI::Application::Plugin::AutoRunmode; use CGI::Application::Plugin::Session; sub default : StartRunmode { my $self = shift; my $output; # get current access count my $access_count = $self->session->param('access_count') || 0; # increment access count $access_count++; # store new access count in session $self->session->param(access_count => $access_count); # get CGI object out of application my $q = $self->query; #build output $output = $q->start_html( -head => $q->meta({ -http_equiv => 'Content-Type', -content => 'text/html; charset=UTF-8' }), -title => 'access count application' ); $output .= $q->div("accessed $access_count time(s) this session"); $output .= $q->div(' '); $output .= $q->div( $q->a( {-href => $q->self_url} => 'access again' ) ); $output .= $q->end_html; # set charset $self->header_add( -type => "text/html; charset=UTF-8"); # give output to app to send to user return( $output ); } $ perl cgiapp.pl Set-Cookie: CGISESSID=357a2d9c8f6ec5830c08beb44d12afb2; path=/ Date: Tue, 28 Dec 2010 01:31:47 GMT Content-Type: text/html; charset=UTF-8 access count application
accessed 1 time(s) this session
access again