NAME
MojoX::UserAgent::CookieJar - a place to store Mojo::Cookie::Response objects.
SYNOPSIS
my $jar = MojoX::UserAgent::CookieJar->new;
# ...
$jar->store($resp_cookies_array_ref);
$jar->store($resp_cookie1, $resp_cookie2);
# ...
my $cookies = $jar->cookies_for_url($url);
DESCRIPTION
This is the class used by MojoX::UserAgent to store session cookies. Note that it does no validation itself. It does, however, expire cookies as appropriate based on either their "expires" or "max_age" properties.
ATTRIBUTES
MojoX::UserAgent::CookieJar implements the following attributes.
size
my $jar_size = $jar->size;
The number of cookies currently stored in the jar.
METHODS
MojoX::UserAgent::CookieJar inherits all methods from Mojo::Base and implements the following new ones.
store
my $jar_size = $jar->store($resp_cookie1, $resp_cookie2);
Store cookies in the jar. Arguments: either a reference to an array of Mojo::Cookie::Response objects or a set of such objects. All cookies must have a domain property. If cookies have both expires and max_age properties, max_age wins. Returns the number of cookies currently stored in the jar.
cookies_for_url
my $cookies = $jar->cookies_for_url($url);
Get the cookies that match a given URL. You may pass in either a URL string or a Mojo::URL object. Returns a reference to an array of Mojo::Cookie::Response objects. Turning these into Mojo::Cookie::Request objects is left as an exercise for the caller.