NAME

Mojo::UserAgent::CookieJar - Cookie jar for HTTP user agents

SYNOPSIS

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;
}

DESCRIPTION

Mojo::UserAgent::CookieJar is a minimalistic and relaxed cookie jar for HTTP user agents.

ATTRIBUTES

Mojo::UserAgent::CookieJar implements the following attributes.

my $max_cookie_size = $jar->max_cookie_size;
$jar                = $jar->max_cookie_size(4096);

Maximum cookie size in bytes, defaults to 4096.

METHODS

Mojo::UserAgent::CookieJar inherits all methods from Mojo::Base and implements the following new ones.

add

$jar = $jar->add(@cookies);

Add multiple Mojo::Cookie::Response objects to the jar.

empty

$jar->empty;

Empty the jar.

extract

$jar = $jar->extract($tx);

Extract response cookies from transaction.

find

my @cookies = $jar->find($url);

Find Mojo::Cookie::Request objects in the jar for Mojo::URL object.

inject

$jar = $jar->inject($tx);

Inject request cookies into transaction.

SEE ALSO

Mojolicious, Mojolicious::Guides, http://mojolicio.us.