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

I am trying to automate the entering of a password for a secure site that thereafter uses cookies. I receive a "302 Found" Error after POSTing that form. When I try to access parts of the site that I would see if I properly logged in, they tell me that I have to sign in. On another website that I automated logins for, I get the same 302 Found, but I can access other parts of the site without trouble. How can I let my program know to follow redirection? I guess redirecting isnt important in the site that works but is in this one.

Thanks a lot monks, below is code.

use strict; use LWP::Simple; use LWP; use HTTP::Cookies; my $browser=LWP::UserAgent->new; $browser->cookie_jar({}); my $response=$browser->post( 'https://id.thewebsite.com/exec?c=user&f=login&_ref=User%5CLoginForm"' +, [ 'un'=>"username", 'pw'=>"password", 'as'=>"stuffthatwashidden", 'sid'=>"stuffthatwashidden", 'rs'=>"stuffthatwashidden", 'rc'=>'stuffthatwashidden' ], ); print $response->status_line;

Replies are listed 'Best First'.
Re: how to allow POST to redirect
by Anonymous Monk on Nov 07, 2004 at 22:57 UTC
    perldoc LWP::UserAgent:
    $ua->requests_redirectable $ua->requests_redirectable( \@requests ) This reads or sets the object’s list of request names that "$ua->redirect_ok(...)" will allow redirection for. By default, this is "[’GET’, ’HEAD’]", as per RFC 2616. To change to include ’POST’, consider: push @{ $ua->requests_redirectable }, ’POST’;
      Interesting, except according to the RFC one should use 303

      --
      I'm not belgian but I play one on TV.