Subject: | HTTP::Cookies::extract_cookies() discards cookies named "expires" |
According to Netscape's Cookie Specification [1], the first parameter of a Set-Cookie header is the name and value of the cookie. This example
below creates a Set-Cookie header with the cookie name equal to
"expires", and then prints out the resulting HTTP::Cookies object. It
should print something like the following:
Set-Cookie3: expires=10101; path="/"; domain=www.en.com; discard; version=0
Instead, it prints the following, completely eliminating the key and value:
Set-Cookie3: Discard; path="/"; domain=www.en.com; version=0
Mozilla Firefox, links2, and Internet Explorer all handle cookies with a
name of "expires" properly (that is, they do not discard them.)
#!/usr/bin/perl -w
use strict;
use HTTP::Cookies;
use HTTP::Response;
use HTTP::Request;
my $cookie_jar = new HTTP::Cookies;
my $request = HTTP::Request->new(GET => 'http://www.en.com/');
my $response = HTTP::Response->parse
("HTTP/1.1 302 Moved\r\nSet-Cookie: expires=10101\r\n\r\n");
$response->request($request);
$cookie_jar->extract_cookies($response);
print $cookie_jar->as_string();
__END__
[1] Client Side State - HTTP Cookies
Netscape Communications Corporation
<http://wp.netscape.com/newsref/std/cookie_spec.html>