Why cookies are not saved in the file?
Since WWW :: Mechanize is built on top of LWP :: UserAgent , you process cookies just like in LWP :: UserAgent . You can make a cookie or hash memory in memory.
If you do not want to save cookies in a file, use an empty hash link when creating the mech object:
use WWW::Mechanize; my $mech = WWW::Mechanize->new( cookie_jar => {} );
If you want to use the new file, create a new HTTP :: Cookies object:
use WWW::Mechanize; my $mech = WWW::Mechanize->new( cookie_jar => HTTP::Cookies->new( file => "$ENV{HOME}/.cookies.txt" ) );
If you want to load a specific cookie for the browser, use the correct module for it:
use WWW::Mechanize; my $mech = WWW::Mechanize->new( cookie_jar => HTTP::Cookies::Netscape->new( file => $filename ) );
If you don't want to use cookies at all, use undef explicitly:
use WWW::Mechanize; my $mech = WWW::Mechanize->new( cookie_jar => undef );
All this is in the docs.
source share