in reply to LWP and HTML 302 Error

Please check the documentation for HTTP::Request::Common.

The POST method does not take a hashref as an argument. It takes an arrayref instead. ( try  [ ] instead of  { }, see perlref if you don't understand).

update: oops. apparently it does, not documented at all (i'm kind of a stickler for things like that)

###### line 113 in sub form_data in HTTP/Request/Common.pm my @data = ref($data) eq "HASH" ? %$data : @$data; # copy
update: you say you "can log in fine", how do you know?

I don't see $cookie_jar->add_cookie_header($request); or $cookie_jar->extract_cookies($response); anywhere. What good is an empty cookie jar, in which you never reach?

Please check the HTTP::Cookies documentation.

update:
I was reviewing some of my nodes, and then I noticed $ua->cookie_jar ( you know, it would've be nice if somebody pointed this out to me). Turning to the documentation would've still been helpfull though (you'd have known the following, and could've dismissed my comments quickly ;)

$ua->cookie_jar([$cookies]) Get/set the HTTP::Cookies object to use. The default is to have no cookie_jar, i.e. never automatically add ``Cookie'' headers to the requests.

 

Look ma', I'm on CPAN (and I just saved the day).


** The Third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
login just fine
by Anonymous Monk on May 21, 2002 at 15:09 UTC
    I know I can log in fine because I can return $b, which was set as $r->as_string, and do so from a browser running the script, so I get the page that shows up when I am logged in.

    What can add_cookie_header($request) or extract_cookies($response) do for me? I have never used those. Thanks for your help and time!
      add_cookie_header($request) and extract_cookie($response) store and extract a cookie from your cookie jar.

      The autosave option only saves the cookie file during destruction.

      You can see the page, because you send the username/password.

      The reason you're having problems the 2nd time, is because when you login, you're issued a cookie, which you simply discard.

      Since you login via Login.cfm, and your 2nd request is to Page.cfm, you must send the cookie you were given by Login.cfm.

      That's how cookie based authentication works. You send your credentials, and get issued a cookie, which you use as credentials istead.

      Now please go read the HTTP::Cookies documentation like I suggested (you could've saved yourself a day or two)

      update:
      I was reviewing some of my nodes, and then I noticed $ua->cookie_jar ( you know, it would've be nice if somebody pointed this out to me). Turning to the documentation would've still been helpfull though (you'd have known the following, and could've dismissed my comments quickly ;)

      $ua->cookie_jar([$cookies]) Get/set the HTTP::Cookies object to use. The default is to have no cookie_jar, i.e. never automatically add ``Cookie'' headers to the requests.

       

      Look ma', I'm on CPAN.


      ** The Third rule of perl club is a statement of fact: pod is sexy.
        I read the docs now, let me see if I got this straight (going to have to try it tonight when I'm not at work). I need to save the file with $cookie_jar->save( $file ); and then load the file with $cookie_jar->load( $file );.
        Then loading that will allow me to do my 2nd post? Thanks for the help.

        Michael Jensen
        InShift Technologies
        http://www.inshift.com
        michael@inshift.com