#!/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"; }

In reply to Cookie Maker by isotope

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.