NAME

Mojo::UserAgent::CookieJar::Role::Persistent - Persist cookies to Netscape file

SYNOPSIS

# Add role to existing CookieJar in UserAgent, then load cookies
$ua->cookie_jar->with_roles('+Persistent')->load;

# After a response which adds cookies e.g. logging into a website
$ua->cookie_jar->save;

DESCRIPTION

Provides methods for saving and loading of cookies to the Netscape file format.

ATTRIBUTES

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

file

my $file = $cookie_jar->file;
my $cookie_jar = $cookie_jar->file('cookies.txt');

File to save/load cookies to/from, defaults to 'cookies.txt'.

expires_in

my $cb = $cookie_jar->expires_in;
my $cookie_jar = $cookie_jar->expires_in(sub { time + (60*10) });

A callback used to determine the expiration time, defaults to current time + 10 minutes.

session

my $bool = $cookie_jar->session;
my $cookie_jar = $cookie_jar->session($bool);

Include session cookies in output, defaults to 1.

METHODS

Mojo::UserAgent::CookieJar::Role::Persistent implements the following methods.

save

$cookie_jar->save;

Saves the cookies in the CookieJar to file.

load

$cookie_jar->load;

Adds cookies from file into the CookieJar.

ACKNOWLEDGEMENTS

Grinnz

Reviewed a draft implementation.

sri

Advised on examples in documentation.

TODO

Write a test suite

AUTHOR

CandyAngel <candyangel@electricjungle.org>

LICENSE AND COPYRIGHT

Copyright (c) 2017 CandyAngel <candyangel@electricjungle.org>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.