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.

1 Comment

Awesome! So glad to hear you find it useful. :)

Leave a comment

About Mark Stosberg

user-pic I help maintain CGI::Application, CGI.pm, CGI::Session and Data::FormValidator. I'm interested in balancing technology with simplicity and sustainability.