Mojo::UserAgent::CookieJar::Role::Persistent - Persist cookies to Netscape file
# 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;
Provides methods for saving and loading of cookies to the Netscape file format.
Mojo::UserAgent::CookieJar::Role::Persistent implements the following attributes.
my $file = $cookie_jar->file; my $cookie_jar = $cookie_jar->file('cookies.txt');
File to save/load cookies to/from, defaults to 'cookies.txt'.
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.
my $bool = $cookie_jar->session; my $cookie_jar = $cookie_jar->session($bool);
Include session cookies in output, defaults to 1.
Mojo::UserAgent::CookieJar::Role::Persistent implements the following methods.
$cookie_jar->save;
Saves the cookies in the CookieJar to file.
$cookie_jar->load;
Adds cookies from file into the CookieJar.
Reviewed a draft implementation.
Advised on examples in documentation.
CandyAngel <candyangel@electricjungle.org>
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.
To install Mojo::UserAgent::CookieJar::Role::Persistent, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::UserAgent::CookieJar::Role::Persistent
CPAN shell
perl -MCPAN -e shell install Mojo::UserAgent::CookieJar::Role::Persistent
For more information on module installation, please visit the detailed CPAN module installation guide.