Thank you chromatic! The code in question works perfectly when the $perlmonks variable is changed to "www.perlmonks.org". I guess the upside to this debacle is learning a few different techniques for posting to cookie-login sites, and understanding why many cookies are set in the form: .domain.net

Joy!

Update: Here's the sub using merlyn's instructions for the cookie_jar. When using this code for perlmonks note the odd node_id=>'16046' parameter in the requests. This is done to ensure a small response. In this example it's an xml node. If omitted the monastery gates is returned making the operation much heavier than it needs to be.
sub sendit{ my$message = shift; my$ua = LWP::UserAgent->new; $ua->cookie_jar(HTTP::Cookies->new); my$req = POST ($pmurl, [ op=>'login',user=>$username,passwd=>$password,node_id=>'16046']); my$res = $ua->request($req); $req = POST ($pmurl, [ op=>'message',message=>$message,node_id=>'16046']); $res = $ua->request($req); print header; &talk(); }

Update2: After experimenting i found that the saved cookie file will be empty when merely using:

$ua->cookie_jar(HTTP::Cookies->new(file => ".cookies", autosave => 1)) +;
unless the cookie_jar is told to save cookies without an expiration date by adding the ignore_discard parameter:
$ua->cookie_jar(HTTP::Cookies->new(file => ".cookies", autosave => 1, +ignore_discard => 1));
or, better yet, by not using ignore_discard, but instead adding an 'expires' parameter to the login request:
my$req = POST ($pmurl, [ op=>'login',user=>$username,passwd=>$password,expires=>'+10y',node_id= +>'16046']);
Thanks merlyn.

In reply to Re: Re: Login, post, reload. by epoptai
in thread Login, post, reload. by epoptai

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.