use HTTP::Cookies; use WWW::Mechanize; my $cj = HTTP::Cookies->new( autosave => 1, ignore_discard => 1 ); my $mech = WWW::Mechanize->new( cookie_jar => $cj ); $mech->get( 'http://example.com/login.action' ); if ($mech->success()) { $mech->submit_form( form_name => 'loginform', fields => { os_username => 'username', os_password => 'password' } ); } if ($mech->success()) { $mech->follow_link( text => 'Training'); # This is where I get redirected to the login page again! }