Mojo::UserAgent::CookieJar - Cookie jar for HTTP user agents
use Mojo::UserAgent::CookieJar; # Add response cookies my $jar = Mojo::UserAgent::CookieJar->new; $jar->add( Mojo::Cookie::Response->new( name => 'foo', value => 'bar', domain => 'localhost', path => '/test' ) ); # Find request cookies for my $cookie ($jar->find(Mojo::URL->new('http://localhost/test'))) { say $cookie->name; say $cookie->value; }
Mojo::UserAgent::CookieJar is a minimalistic and relaxed cookie jar based on RFC 6265 for Mojo::UserAgent.
Mojo::UserAgent::CookieJar implements the following attributes.
my $size = $jar->max_cookie_size; $jar = $jar->max_cookie_size(4096);
Maximum cookie size in bytes, defaults to 4096.
4096
Mojo::UserAgent::CookieJar inherits all methods from Mojo::Base and implements the following new ones.
$jar = $jar->add(@cookies);
Add multiple Mojo::Cookie::Response objects to the jar.
my @cookies = $jar->all;
Return all Mojo::Cookie::Response objects that are currently stored in the jar.
$jar->empty;
Empty the jar.
$jar->extract(Mojo::Transaction::HTTP->new);
Extract response cookies from transaction.
my @cookies = $jar->find(Mojo::URL->new);
Find Mojo::Cookie::Request objects in the jar for Mojo::URL object.
$jar->inject(Mojo::Transaction::HTTP->new);
Inject request cookies into transaction.
Mojolicious, Mojolicious::Guides, http://mojolicio.us.
To install Mojolicious, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious
CPAN shell
perl -MCPAN -e shell install Mojolicious
For more information on module installation, please visit the detailed CPAN module installation guide.