Mojo::UserAgent::CookieJar::Role::Persistent - Persist cookies to Netscape file
# Create a UserAgent with persistable cookies and load existing cookies my $cj = Mojo::UserAgent::CookieJar->with_roles('+Persistent')->new; $cj->load; my $ua = Mojo::UserAgent->new(cookie_jar => $cj); # After cookie adding response e.g. logging into a website $cj->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.
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.