Skip to content

Instantly share code, notes, and snippets.

@ikolar
Created July 6, 2009 00:36
Show Gist options
  • Save ikolar/141195 to your computer and use it in GitHub Desktop.
Save ikolar/141195 to your computer and use it in GitHub Desktop.
#! /usr/bin/env perl -W
use strict;
use HTTP::Response;
use HTTP::Request;
use HTTP::Cookies;
=pod
construct a cookie jar from a "Cookie: .." string you retrieve from LiveHttpHeaders or elsewhere
this should have been available out of the box :/
=cut
sub get_cookie_jar() {
my $r = HTTP::Response->new(200, "Crooked as a hooker's smile",
HTTP::Headers->new("Set-Cookie" => 'Cookie string');
$r->request(HTTP::Request->new("GET" => "http://www.facebook.com")); # enter domain
my $cookie_jar = HTTP::Cookies->new();
$cookie_jar->extract_cookies($r);
return $cookie_jar;
}
print &get_cookie_jar()->as_string;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment