Thanks to Olaf Alders for HTTP::CookieMonster
The old, horrible way, to get a cookie by name with LWP::UserAgent
or WWW::Mechanize
:
my $cookie = $a->cookie_jar->{COOKIES}->{".$SITE_DOMAIN"}->{'/'}->{$COOKIE_NAME};
The new way, with HTTP::CookieMonster:
my $monster = HTTP::CookieMonster->new( cookie_jar => $a->cookie_jar );
my $cookie = $monster->get_cookie($COOKIE_NAME);
Much better. Thank you. I’d love to see something like this built right into WWW::Mechanize.
Awesome! So glad to hear you find it useful. :)