"Tusar K. Nayak" <[EMAIL PROTECTED]> writes:

> #!/usr/bin/perl
>  
> use LWP::UserAgent;
> use HTTP::Request;
> use HTTP::Request::Common;
> use HTTP::Cookies;
>  
>  
> $ua = LWP::UserAgent->new;
>  
> $cookie_jar =
> HTTP::Cookies->new(AutoSave=>1,ignore_discard =>1 ,

It should be 'autosave'; in lower case letters.

> file => 'cookies.txt');
> my $req = HTTP::Request->new(POST => 'http://<some
> url>');
>   
> $req->content_type('application/x-www-form-urlencoded');
>   
> $req->content('UserID=abc&Password=abc123&Submit=Submit');
>  
> # Pass request to the user agent and get a response back
> 
> $res = $ua->request($req);
> 
> $debug=2;
>  
> if ($res->is_success) {
>     print $res->as_string if ($debug > 1);
> } else {
>     print $res->error_as_HTML;
> }
>  
>    #exit;
>  
>  
> $cookie_jar->extract_cookies($res);

You don't need this.  The purpose of the 'cookie_jar' is that $ua will
invoke these by itself when needed.

> $req1=HTTP::Request->new(POST=>'http://<anothercgi>');
>   
> $req1->content_type('application/x-www-form-urlencoded');
> $cookie_jar->add_cookie_header($req1);

You don't need this.

> $req1->content('name=abc&status=A');
>  
> $res1 = $ua->request($req1);
> 
> #print $req1->as_string; # here i do not see the header
> #exit;                         # Cookie: name=value;path=/
> #print $res1->as_string;
> #exit;
>  
>  
> if ($res1->is_success) {
>       print $res1->content; 
> }
> else {
>       print "Bad luck this time\n";
> }

Reply via email to