Inspect cookies using PERL
I've written a short PERL script that lists the current cookies for the
website, but somehow it reports the cookie's domain and expires empty.
What am I doing wrong or am I misunderstanding the mechanics behind
cookies?
The script is live here, but it may help if you visit my blog first so
there are actually some cookies set. Here is my source code:
#!/usr/bin/perl
use warnings;
use strict;
use CGI::Cookie;
my $table;
my %cookies = CGI::Cookie->fetch;
if ( keys %cookies ) {
$table .= "<table border=\"3\" cellpadding=\"5\">";
$table .= "<caption>COOKIES</caption>";
$table .=
"<tr><th>Name</th><th>Domain</th><th>Path</th><th>Expires</th><th
align=\"left\">Value</th></tr
foreach my $cookie ( keys %cookies ) {
$table .= "<tr>";
$table .= "<td>$cookie</td>";
$table .= "<td>" . $cookies{ $cookie }->domain() . "</td>";
$table .= "<td>" . $cookies{ $cookie }->path . "</td>";
$table .= "<td>" . $cookies{ $cookie }->expires . "</td>";
$table .= "<td>" . $cookies{ $cookie }->value . "</td>";
$table .= "</tr>";
}
$table .= "</table>";
}
print "Content-Type: text/html\n\n";
print "<html>\n";
print "<head></head>\n";
print "<body>\n";
print "$table";
print "</body>\n";
print "</html>\n";
Regardless the various cookies on various websites where I install the
script, the output looks like this and Domain and Expires is always empty:
+-----------------------------------------------------------------------------------------+
| Name | Domain | Path | Expires | Value
|
|---------------+--------+------+---------+-----------------------------------------------|
| bb2_screener_ | | / | | 1379007156
2001:980:1b7f:1:a00:27ff:fea6:a2e7 |
+-----------------------------------------------------------------------------------------+
No comments:
Post a Comment