No. Since you do both requests in the same program, the $cookie_jar is stored in memory, so you don't have to save it to a file or load it from a file. You just need to put a cookie in it (extract_cookies), and then put a cookie from the jar in your request (add_cookie_header).

See

$cookie_jar->add_cookie_header($request); The add_cookie_header() method will set the appropriate Cookie:-header for the *HTTP::Request* object given as argument. + The $request must have a valid url attribute before this method is called. $cookie_jar->extract_cookies($response); The extract_cookies() method will look for Set-Cookie: and Set-Cookie2: headers in the *HTTP::Response* object passed as argument. Any of these headers that are found are used to update + the state of the $cookie_jar.

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.

In reply to Re: Re: Re: login just fine by PodMaster
in thread LWP and HTML 302 Error by inblosam

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.