programming-examples/perl/CGI/Writing a cookie to the client computer.pl
2019-11-15 12:59:38 +01:00

43 lines
1.2 KiB
Perl

<HTML>
<HEAD>
<TITLE>Writing a cookie to the client computer</TITLE>
</HEAD>
<BODY>
Click Write Cookie to save your cookie data.
<FORM METHOD = "POST" ACTION = "index.pl">
<STRONG>Name:</STRONG><BR>
<INPUT TYPE = "TEXT" NAME = "NAME"><BR>
<STRONG>Height:</STRONG><BR>
<INPUT TYPE = "TEXT" NAME = "HEIGHT"><BR>
<STRONG>Favorite Color</STRONG><BR>
<INPUT TYPE = "TEXT" NAME = "COLOR"><BR>
<INPUT TYPE = "SUBMIT" VALUE = "Write Cookie">
</FORM>
</BODY>
</HTML>
#!perl
use CGI qw( :standard );
$name = param( NAME );
$height = param( HEIGHT );
$color = param( COLOR );
$expires = "Monday, 11-JUN-10 16:00:00 GMT";
print "Set-Cookie: Name=$name; expires=$expires; path=\n";
print "Set-Cookie: Height=$height; expires=$expires; path=\n";
print "Set-Cookie: Color=$color; expires=$expires; path=\n";
print header, start_html( "Cookie Saved" );
print <<End_Data;
The cookie has been set with the folowing data:<BR><BR>
<FONT>Name:</FONT> $name <BR>
<FONT>Height:</FONT> $height<BR>
<FONT>Favorite Color:</FONT>
<FONT COLOR = $color> $color<BR></FONT>
<BR>Click <A HREF = "read_cookies.pl">here</A>
to read saved cookie.
End_Data
print end_html;