R
Richard Lawrence
Hi all,
My script requests http://foo.bar.com/ with code that looks a little
like this:
my $ua = LWP::UserAgent->new;
my $cookie_jar = HTTP::Cookies->new(file => $cookie_path);
$cookie_jar->load($cookie_path);
$ua->cookie_jar($cookie_jar);
my $req = HTTP::Request->new(GET => "http://foo.bar.com/");
$cookie_jar->add_cookie_header($req);
# Make request
my $res = $ua->request($req);
# HTML back
if ($res->is_success)
{
$cookie_jar->extract_cookies($res);
$cookie_jar->save();
}
This works great, however the site sends back this:
Set-Cookie: name=fred; domain=.bar.com; path=/
which for some reason doesn't get saved in the cookie jar.
I'm not sure if this is because the set-cookie header is badly formed
or non-standard but since Firefox and IE are both happy with it I
really need to make my code happy with it.
Have I done something wrong or is there a way to get this to work?
Many thanks in advance,
Richard
My script requests http://foo.bar.com/ with code that looks a little
like this:
my $ua = LWP::UserAgent->new;
my $cookie_jar = HTTP::Cookies->new(file => $cookie_path);
$cookie_jar->load($cookie_path);
$ua->cookie_jar($cookie_jar);
my $req = HTTP::Request->new(GET => "http://foo.bar.com/");
$cookie_jar->add_cookie_header($req);
# Make request
my $res = $ua->request($req);
# HTML back
if ($res->is_success)
{
$cookie_jar->extract_cookies($res);
$cookie_jar->save();
}
This works great, however the site sends back this:
Set-Cookie: name=fred; domain=.bar.com; path=/
which for some reason doesn't get saved in the cookie jar.
I'm not sure if this is because the set-cookie header is badly formed
or non-standard but since Firefox and IE are both happy with it I
really need to make my code happy with it.
Have I done something wrong or is there a way to get this to work?
Many thanks in advance,
Richard