iamsteve has asked for the wisdom of the Perl Monks concerning the following question:
#!/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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: http::cookie, http::request, How to send my OWN cookie
by kwoff (Friar) on Nov 12, 2001 at 21:34 UTC |