SYNOPSIS use LWP::UserAgent; use HTTP::CookieJar::LWP; my $ua = LWP::UserAgent->new( cookie_jar => HTTP::CookieJar::LWP->new ); #### DESCRIPTION This module is an experimental adapter to make HTTP::CookieJar work with LWP. #### #! perl use strict; use warnings; use feature qw/ say /; use Data::Dumper; use LWP::UserAgent; use HTTP::CookieJar::LWP; my $protocol = 'http://'; my $domain = 'www.foobar.com'; my $path = '/baz'; my $page = '/qux.html'; my $url = join '', $protocol, $domain, $path, $page; my $file = 'cookies.txt'; ## Only here for demo. You would have a cookie file ## made somewhere else, or if not you would pass the ## values directly to HTTP::CookieJar::LWP::add() open( my $write_handle, '>', $file ) or die "open: $!\n"; print $write_handle "Secret_Number=42; Max-Age=300; Domain=$domain; Path=$path\n"; close $write_handle or die "close: $!\n"; my $ua = LWP::UserAgent->new( cookie_jar => HTTP::CookieJar::LWP->new() ); open( my $read_handle, '<', $file ) or die "open: $!\n"; foreach my $cookie ( <$read_handle> ) { chomp $cookie; $ua->cookie_jar->add( $url, $cookie ); } say $ua->cookie_jar->cookie_header( $url ); say Dumper $ua->cookie_jar->cookies_for( $url ); __END__ #### [00:04][nick:~/monks]$ perl 1139766.pl Secret_Number=42 $VAR1 = { 'name' => 'Secret_Number', 'domain' => 'www.foobar.com', 'expires' => 1440486562, 'value' => '42', 'path' => '/baz', 'last_access_time' => 1440486262, 'creation_time' => 1440486262 }; ####