Hmmm, yeah, this sounds like there's a miscommunication going on between your script and the server.

You mention that it uses sessions. Does that mean it's setting a cookie? Your script, as written, will not accept cookies (or rather, forgets them as soon as it receives them).

If I were a login page, on successful POST I might respond with a cookie-setting redirect, then the protected page would check for the cookie, and if it's missing, redirect to the login page. You'd then see exactly the behavior you see above.

You could check for that by installing something like LiveHTTPHeaders for Firefox, or something similar - anything that lets you view the HTTP requests and responses. Then disable cookies and try to log in.

To enable your script to accept cookies, see the cookie_jar method in LWP::UserAgent, or just do this:

# Instead of $ua = LWP::UserAgent->new(); $ua = LWP::UserAgent->new(cookie_jar => {});
Good luck! --Clinton

In reply to Re: LWP form post example not working by clwolfe
in thread LWP form post example not working by perlchild

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.