HTTP::Tiny now with cookies

In early March, the NY Perl Mongers hosted the first hackathon in a space generously provided by the Rubenstein Technology Group.

One of the projects I was pleased to see completed was adding cookie jar support to HTTP::Tiny. A few weeks prior, I had released HTTP::CookieJar in preparation. At the event, Edward Zborowski from Rubenstein volunteered to bring the two together.

Thank you, Edward!

Now, persistent cookie support for HTTP::Tiny is as easy as this:

use HTTP::Tiny;
use HTTP::CookieJar;
use Path::Tiny;

my $jar_file = path("jar.txt");


my $jar = HTTP::CookieJar->new->load_cookies( $jar_file->lines );

my $ua = HTTP::Tiny->new( cookie_jar => $jar );

# ... do stuff that needs cookies ...

$jar_file->spew( join "\n", $jar->dump_cookies( {persistent => 1} ) );
This entry was posted in perl programming and tagged , , , , . Bookmark the permalink. Both comments and trackbacks are currently closed.


  1. Posted March 12, 2013 at 2:49 pm | Permalink

    HTTP::CookieJar::LWP finally makes it easy to get the cookies for a given URL/domain with an LWP-based user agent. I've already integrated into a project now that I now about it. Thanks for that!

    • Posted March 12, 2013 at 2:52 pm | Permalink

      Ah! Glad you like it. I wrote the LWP adaptor so I could use HTTP::Cookies test file with minimal modifications, but figured I could release it in case people want to experiment with it.