Hey. I'm having some difficulties getting cookies to work with WWW::Mechanize. I'm attempting to write a script which logs into various web-based email accounts, inventories the messages in the inbox, gives some output and exits. Nothing more. I don't wish to download the emails or anything. When attempting to access Yahoo!, Hotmail, and others, I appear to be getting errors involving cookies (at least the Yahoo! message explicitly states that). Here is an example of my code: #!/usr/bin/perl
# turn on perl's safety features use strict; use warnings; # create a new browser use WWW::Mechanize; my $browser = WWW::Mechanize->new( agent => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows 98', cookie_jar => {file => "$ENV{'HOME'}/scripts/cookies.dat"}, protocols_allowed => undef, requests_redirectable => ['GET', 'HEAD', 'POST'] ); # tell it to get the main page $browser->get("http://mail.yahoo.com/"); die "ERROR: ", $browser->response->status_line unless $browser->success; # okay, fill in the login form $browser->form_number(1); $browser->field("login", <username>); $browser->field("passwd", <password>); $browser->click(); # click on the link that matches the module name #$browser->follow($module_name); my $url = $browser->uri; # launch a browser... system('mozilla', $url); exit(0); The launched browser, if the login was successful, should take me to my inbox. However, I get a page stating that my browser doesn't allow cookies. Has anyone attempted logins with Yahoo or any of these other services? Is there something in their auth/cookie mechanism that needs special handling? Thanks, Brian