#!/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 i
+nstead of the form##
#!/usr/bin/perl
use CGI;
$query = new CGI;
if($query->cookie('user')){
print $query->header;
$content = $query->cookie('user');
@new = split ("=", $content);
foreach $user (@new){
if($user !~ /^user$/){
print "Welcome back $user\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";
}
else{
print $query->header;
print "Testing a page with cookies
\n \n";
print "\n\n";
#construct the form that asks for the username...
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";
}