Hi
I'm using perl to automate some testing on a web site.
I use the useragent, however once I have used it to log in to the site, it redirects to the logged in page then promptly seems to drop the cookies that get set to prove the login. Hence when the script follows a link on the page it goes straight to the login page again since logged in status has failed to verify.

Even explicitly setting and saving the cookies on each request, ie
        $ua->cookie_jar($cookies);
        my $content = $ua->request($req)->as_string;
        $cookies = $ua->cookie_jar();

seems to fail.

One possibility may be that when the cookies get first set, the page is followed by a redirect, around which I can't effectively grab and explicitly set the cookies. Is it likely that the cookies are being lost there ?

Anyone got any suggestions (it's fairly urgent now of course :)

Thanks

Specimen

In reply to using cookies with UserAgent by Specimen

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.