#!/usr/bin/perl use CGI; $query = new CGI; if($ENV{'HTTP_COOKIE'}){ print $query->header; print"
\n";

$cook = $ENV{'HTTP_COOKIE'};
@cookies = split /;/, $cook;
foreach $new (@cookies){

    print "Welcome back:" . $new;
    }
    print "
\n"; } else{ if($query->param('name')){ $cookie = $query->cookie(-name=>'user', -value=>$query->param('name'), -expires=>'+30d', -path=>'/'); print $query->header(-cookie=>$cookie); print "Thank you for registering!\n"; print "When you view this page again you will se a welcoming message instead of the form
"; } else{ print $query->header; print "

Testing a page with cookies

\n\n"; print "

\n\n"; #construct the form that asks for the username... print "
"; print "Please type your name: "; print "\n"; print "\n"; print "
\n\n"; &end_page; } } sub start_page{ print "Testing a script with cookies\n\n"; print "\n"; } sub end_page{ print "\n\n"; print "\n"; }