LJ Archive

Listing 2: show-cookies.pl, Program to Display All Cookies

#!/usr/bin/perl -w
use strict;
use diagnostics;
use CGI;

# Create an instance of CGI
my $query = new CGI;
print $query->header("text/html");
print $query->start_html(-title =>
   "Cookies received");

# Create a new cookie with a name "counter" and
# the value "1".
my @cookies = $query->cookie;

my $cookie = "";
foreach $cookie (@cookies)
    print "<P>$cookie = ",
   $query->cookie($cookie), "</P>\n";

# Send some HTML as a placeholder
print $query->end_html;
LJ Archive