Dear Monks,

I am having problems with a Moo class I am trying to write inside a Dancer2 web application.

This web app talks to another web app (this one built with Catalyst), a copy of which is also running on my development PC.

I have seen a lot of advice to use WWW::Mechanize for any slightly more complicated web page wrangling. Now, I'm inheriting an LWP::UserAgent object from my module's parent class, which has the appropriate session cookie to log into the other web app (the Catalyst one) in order to fetch a very tiny, simple JSON document. But when I try to connect to the Catalyst web app in my code, I always just get redirected to the login page.

I expected LWP::UserAgent to just be able to get the JSON document with its transparent cookie handling facility, but it can't. I've checked and it does seem to be sending the cookie, but again, I just get the login page.

Of course, it all works fine in my browser (Firefox). It's enterprise software so I can't do anything like hard code credentials (not a great idea anyway) or grab the cookie from my Firefox store.

Is there a way to grab the cookie jar off the LWP::UserAgent object and hand it over to a WWW::Mechanize object?

Or simply to 'promote' my inherited LWP::UserAgent object to a WWW::Mechanize object?


In reply to Pass cookie jar between LWP::UserAgent and WWW::Mechanize objects by Dumu

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.