I want to make a "Cookie" and send it thru a request for another URL, so that it can read my "cookie" authentication.
#!/usr/bin/perl use LWP::UserAgent; use HTTP::Request; use HTTP::Headers; use HTTP::Response; use HTTP::Cookies; $hdrs = new HTTP::Headers();#all in case $url ="http://mamadada.com"; $jar = HTTP::Cookies->new; $key="INFO"; $val="36D0007E46195FDC2DA0DE9D2377E1E094AA7B095C8C1B70C4B2627A295FB765 +9D37F3BC342C35EEAED5D7A631D1B287A86D4497771A20B05A5D7624AE891A574105D +1A2ACA17E00FE493C2F9E23D30EBD4B1F1A6D6E6871A5FA7184058AD675"; $domain="foo.com"; $file ="mycookie.txt"; $maxage = 100000; $jar->set_cookie($key, $val, $domain, $maxage); $jar->save( $file ); $req = new HTTP::Request(GET, $url, $hdrs); $jar->add_cookie_header($req); #make a useragent so we can spoof the server as to what client we actu +ally are $ua = new LWP::UserAgent; $ua->agent('Mozilla/4.0 (Compatable; MSIE 5.01; Windows NT 5.0)'); $ua->cookie_jar($jar); $jar->extract_cookies($responce); $responce = $ua -> request($req); if($responce->is_success) { print $responce->headers_as_string; print "\n"; print $responce->content; } else { print "Content-Type: 'text/html'\n\n"; print $responce->error_as_HTML; }

I know this code was copy-paste and probably has errors
the main thing here is i want to get or post a web page and send my "own" cookie to the server for reading.


I need to know the correct way to save my own cookie and then how to send it when i "get" or "post" a URL so the "GET" server can read it although it doesnt really exist.

In reply to http::cookie, http::request, How to send my OWN cookie by iamsteve

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.