Reputation: 43683
Simple perl code is:
use WWW::Scripter;
...
my $w = WWW::Scripter->new('agent' => 'myAgent');
$w->use_plugin('JavaScript');
...
$w->get($url);
### WWW::Mechanize automatic cookies = good for now
$w->add_header(Referer => $url);
$url = $w->document->getElementsByTagName('a')->[0]->href;
$w->get($url);
...
### WWW::Mechanize automatic cookies = NOT good for now
### ! need to clear cookie jar here !
...
$w->add_header(Referer => $url);
$url = $w->document->getElementsByTagName('a')->[0]->href;
$w->get($url);
One of good feature of WWW::Mechanize
is automatic cookies, which is good at some point, but sometimes cookies need to be cleared. How?
Upvotes: 0
Views: 543
Reputation: 39158
The WWW::Mechanize
method cookie_jar
returns a HTTP::Cookies
object. The relevant method is indeed named clear
.
Upvotes: 2
Reputation: 7793
Looking at the documentation, can't you just reset the cookie jar attribute?
e.g.
$w->cookie_jar({});
Upvotes: 0