#!/usr/bin/perl use CGI ':standard'; use strict; my $header; if (param()) { my $cookie = cookie(-name => param('name'), -value => param('value')); $header = header(-cookie => $cookie); Delete_all(); } else { $header = header(); } print $header; print start_html("Cookie Summary"), h1("Cookies"); show_cookies(), "
\n"; show_form(); print hr(), "
\n", $header, "
\n"; exit; sub show_cookies { my @cookie_names = cookie(); print "\n"; for my $name (sort @cookie_names) { print Tr(td([$name, cookie($name)])); } print "
\n", end_html; } sub show_form { print start_form; print "New cookie name: ", textfield('name'), br(); print "New cookie value: ", textfield('value'), br(); print submit(), end_form; }