in reply to Missing cookies with LWP::UserAgent and HTTP::Cookies

You should add your cookie jar before the request.
... my $cjar = HTTP::Cookies->new(); my $ua = LWP::UserAgent->new(keep_alive => '1', timeout => $timeout); $ua->cookie_jar($cjar); my $req = HTTP::Request->new(GET => $url); my $response = $ua->request($req);
Boris

Replies are listed 'Best First'.
Re^2: Missing cookies with LWP::UserAgent and HTTP::Cookies
by neilwatson (Priest) on Apr 12, 2006 at 18:34 UTC
      Then the server did not send a cookie! Here is a complete TESTED working example, that prints a cookie.
      use LWP::UserAgent; use HTTP::Cookies; my $cjar = HTTP::Cookies->new(); my $ua = LWP::UserAgent->new( keep_alive => '1', ); $ua->cookie_jar($cjar); my $req = HTTP::Request->new( GET => 'http://derstandard.at/' ); my $response = $ua->request($req); print $cjar->as_string;
      Boris
        This is interesting. I tested with several URLs and yes, it appears that the server did not send a cookie. However, if I visit the same URL with Firefox I receive a cookie. Does this mean that there is a server side mechanism that may not send cookies to all agents?

        Neil Watson
        watson-wilson.ca