[perl]代码库
#-----------------------------
$preference_value = cookie ( "preference name" );
#-----------------------------
$packed_cookie = cookie ( -NAME => "preference name",
-VALUE => "whatever you'd like",
-EXPIRES => "+2y" );
#-----------------------------
print header ( -COOKIE => $packed_cookie );
#-----------------------------
# download the following standalone program
#!/usr/bin/perl -w
# ic_cookies - sample CGI script that uses a cookie
use CGI qw ( :standard );
use strict;
my $cookname = "favorite ice cream";
my $favorite = param ( "flavor" );
my $tasty = cookie ( $cookname ) || 'mint';
unless ( $favorite )
{
print header(), start_html ( "Ice Cookies" ), h1 ( "Hello Ice Cream" ),
hr(), start_form(),
p ( "Please select a flavor: ", textfield ( "flavor",$tasty ) ),
end_form(), hr();
exit;
}
my $cookie = cookie (
-NAME => $cookname,
-VALUE => $favorite,
-EXPIRES => "+2y",
);
print header ( -COOKIE => $cookie ),
start_html ( "Ice Cookies, #2" ),
h1 ( "Hello Ice Cream" ),
p ( "You chose as your favorite flavor `$favorite'." );
#-----------------------------
by: 发表于:2017-09-15 16:57:08 顶(0) | 踩(0) 回复
??
回复评论