#!/usr/bin/perl use CGI qw(-any); $query = new CGI; $out = $query->start_html({-title => "Cookie test page"}); $out .= $query->h1("Looking for a cookie."); $out .= $query->p("I'm looking for a cookie with a name of ".$query->span({-style =>"color: red"},'visits')." using the statement \$result = \$query->cookie({-name => \"visits\"});"); $result = $query->cookie({-name => "visits"}); if ( ! $result ){ $out .= $query->p($query->span({-style =>"color: red"},"Did not find a cookie with that name.")); $newval = 2; } else { $out .= $query->p($query->span({-style =>"color: green"},"The value of the 'visits' cookie is '$result'.")); $newval = $result + 1; } $out .= $query->p("I will now give the 'visits' cookie a value of $newval."); $vcookie = $query->cookie({-name => 'visits', -value => $newval}); $out .= $query->a({-href => "cookiedough.cgi"},"Refresh or reload this page to see if anything has changed."); $out .= $query->p(); $out .= $query->a({ -href => "clear.cgi"}, "Click here to remove the 'visits' cookie."); $out .= $query->p().$query->a({-href => "seecookie.cgi", -target => "_blank"}, "Click here to see the perl code for this page."); $out .= $query->end_html; print $query->header({-cookie => $vcookie}); print $out;