Looking at your original snippet, you can grab the output of your call to $ua->cookie_jar(...)
my $ua = LWP::UserAgent->new;
my $jar = $ua->cookie_jar({
file => $full_path_to_script_dir."/cookies",
hide_cookie2 => 1,
autosave => 1,
ignore_discard => 1});
#... do surfing....
#edit jar
$jar->clear_temporary_cookies
If you happen to already have a cookie_jar object or want a non-standard one, you can create a cookie_jar and then add it to your UserAgent.
Also, these tips also work for things that subclass LWP::UserAgent, like WWW::Mechanize.
my $jar = MyCookieJar->new({
file => $path_to_cookies, %options
});
# directly at new:
my $ua = LWP::UserAgent->new( cookie_jar => $jar);
# or later, via cookie_jar
$ua->cookie_jar( $jar );
|