set a cookie while sending PERL HTTP::Request
- by dexter
i have created HTTP::Request which looks like this:
#!/usr/bin/perl
require HTTP::Request;
require LWP::UserAgent;
$request = HTTP::Request->new(GET => 'http://www.google.com/');
$ua = LWP::UserAgent->new;
$ua->cookie_jar({file => "testcookies.txt",autosave =>1});
$response = $ua->request($request);
if($response->is_success){
print "sucess\n";
print $response->code;
}
else {
print "fail\n";
die $response->code;
}
now, When i send Request:
$request = HTTP::Request->new(GET => 'http://www.google.com/');
$ua = LWP::UserAgent->new;
$ua->cookie_jar({file => "testcookies.txt",autosave =>1});
i want to set a cookie which might look like..
$request = HTTP::Request->new(GET => 'http://www.google.com/');
$ua = LWP::UserAgent->new;
$ua->new CGI::Cookie(-name=>"testCookie",-value=>"cookieValue");
$ua->cookie_jar({file => "testcookies.txt"});
gives error though.
AND,
want to log the http response codes in the file
please help
thank you