perl - cookies

  • From: "Lamar Upshaw" <lupshaw@xxxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 25 Jun 2008 20:27:22 -0700

I'm playing with perl using cookies again, trying to brush up on what I once knew. *smile* Below are the codes in two files. Both are giving me an internal server error (500), but I can't figure out what small thing i'm missing, which I should know. lol The two files are cookiesave.pl, and cookieget.pl. They are pretty self explanitory. If someone could either point out my mistake, or point me in the right direction for tutorial help, I would be very grateful.


cookiesave.pl
#!/usr/bin/perl
use strict;
use CGI;
my $query = new CGI;
my $username="tigger";
#Define the cookie content
my $cookie = $query->cookie(-name => 'username',-value => $username,-expires => '+90d');

#set the cookie in the header
$query->header(-cookie => $cookie);
print <<EOF;
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<title>
cookie test part 1
</title>
</head>
<body>
<center>
<h1>Saved cookie</h1>
<p>
The Cookie should be saved.
<br />
<a href="cookieget.pl">
Click here to see if the cookie info can be retrieved.
</a>
</p>
</center>
</body>
</html>
EOF


cookieget.pl
#!/usr/bin/perl
use strict;
use CGI;
my $query = new CGI;
my $username= $query->cookie('username');
$query->header;
print <<EOF;
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<title>
cookie test part 2
</title>
</head>
<body>
<center>
EOF
if (defined($username))
{
print <<EOF;
<h1>Retrieved cookie</h1>
<p>
The Cookie retrieved has the username: $username.
</p>

EOF
}
else
{
print <<EOF;
<h1>no cookie found</h1>
<p>
There was no cookie found. please try rewriting part 1 of the cookie test.
</p>
EOF
}
print <<EOF;
</center>
</body>
</html>
EOF


Thanks again for any and all assistance.

With All Respect,
Upshaw, Lamar T
__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: