#!/usr/local/bin/perl
$| = 1;
use CGI qw(:form);
use URI::Escape;
my $query = new CGI;
my $name = $query->param('name');
if ($name eq "") {
form();
}
else {
my $value = $query->param('value');
my $exp = $query->param('exp');
if ($query->param('cookie_action') eq "Delete") {
$exp = "-1d";
}
my $path = $query->param('path');
my $cookie = $query->cookie(-name=>$name,
-value=>$value,
-expires=>$exp,
-path=>$path);
print $query->header(-cookie=>$cookie,
-expires=>'-1d',
-location=>'cookie.cgi');
print <<"End";
<HTML>
<HEAD>
<TITLE>Cookie maker</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<FONT SIZE="+2"><A HREF="cookie.cgi">Refresh</A></FONT><BR>
</BODY>
</HTML>
End
}
sub form {
print $query->header(-expires=>'-1d');
print <<"End";
<HTML>
<HEAD>
<TITLE>Cookie Maker</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H1>Please enter your cookie parameters</H1>
<FORM ACTION="cookie.cgi" METHOD="GET">
<INPUT TYPE="text" NAME="path" VALUE="/cgi-bin/"> Path<BR>
<INPUT TYPE="text" NAME="name" VALUE=""> Cookie Name<BR>
<INPUT TYPE="text" NAME="value" VALUE=""> Cookie Value<BR>
<INPUT TYPE="text" NAME="exp" VALUE="+3M"> Expiration date<BR>
<INPUT TYPE="submit" NAME="cookie_action" VALUE="Make cookie">
</FORM>
<BR>
End
mycookies();
print <<"End";
</BODY>
</HTML>
End
}
sub mycookies {
print "Your cookies:\n";
print "<TABLE BGCOLOR=\"#FFFF00\" BORDER=\"1\">\n";
print "<TR><TH>Name</TH><TH>Value</TH><TH>Cookie Path</TH><TH>Rene
+wal Date</TH><TH>Action</TH></TR>\n";
my @cookies = split(/\; /, $ENV{'HTTP_COOKIE'});
foreach my $cookie (@cookies) {
$cookie = uri_unescape($cookie);
my ($name, $value) = split(/=/,$cookie);
print "<TR>\n";
print "<FORM ACTION=\"cookie.cgi\" METHOD=\"GET\">\n";
print "<INPUT TYPE=\"hidden\" NAME=\"name\" VALUE=\"$name\">\n
+";
print "<INPUT TYPE=\"hidden\" NAME=\"value\" VALUE=\"$value\">
+\n";
print "<TD>$name</TD>\n";
print "<TD>$value</TD>\n";
print "<TD><INPUT TYPE=\"text\" NAME=\"path\" VALUE=\"/cgi-bin
+/\"></TD>\n";
print "<TD><INPUT TYPE=\"text\" NAME=\"exp\" VALUE=\"+3M\"></T
+D>\n";
print "<TD><INPUT TYPE=\"submit\" NAME=\"cookie_action\" VALUE
+=\"Renew\"><INPUT TYPE=\"submit\" NAME=\"cookie_action\" VALUE=\"Dele
+te\"></TD>\n";
print "</FORM>\n";
print "</TR>\n";
}
print "</TABLE>\n";
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|