Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

It seems as though my mech object isn't retrieving all the cookies, only some of them. Is there a way to force it to retrieve all cookies? This is what my mech constructor looks like:
my $mech = WWW::Mechanize->new(autocheck => 1); my $cookie_jar = HTTP::Cookies->new( file => "$my_path\\cookies.dat", autosave => 1, ignore_discard => 1, ); $mech->cookie_jar($cookie_jar); $mech->agent_alias( 'Windows IE 6' ); $mech->quiet(1); # We need to follow redirects for POST too. push @{ $mech->requests_redirectable }, 'POST'; $mech->default_headers->push_header( 'Accept-Language' => 'en-US, en;q +=0.8, *;q=0.1' );

Replies are listed 'Best First'.
Re: mech and cookies?
by perrin (Chancellor) on Apr 24, 2009 at 18:21 UTC
    You're just guessing about cookies. You need to debug it. Do it in a browser where it works and look at the headers you get back. Then compare them to the headers you get back from Mech requests.
Re: mech and cookies?
by Anonymous Monk on Apr 24, 2009 at 14:06 UTC
    Who sets the cookies, which url? Maybe you need to "load" images/frames... to get those missing cookies?
      Here's my issue...I'm trying to use the CPAN module I found for adding friends on Myspace: WWW-Myspace
      Myspace now provides the option to disable captchas by entering a code into the website (So I suspect this sets a cookie they read at a later point ) I've entered the code into the site and no longer encounter these annoying captcha images but the perl module mentioned above still receives them.
      Anyone have any idea why?
Re: mech and cookies?
by jettero (Monsignor) on Apr 24, 2009 at 14:10 UTC
    Are the some it's not saving ... session cookies?

    -Paul