I'm having quite a time trying to get my script 
to set and send cookies.

First, it wont set any at all.  Tested on a very simple
CGI that sets cookies that I grabed off the net, cookies 
are set flawlessly by Netscape, but none are set with this
script.

2nd, it only send to the server in the request the *last* 
cookie in the jar for that particular domain. Again, 
Netscape sends them all. (so its not a problem with the cookies
themselves)

I realy cant see what could possibly be going wrong.  I have 
a feeling im just leaving something out.  I was under the impression
though that if it was left to UserAgent to handle, it would set and
send cookies without hitch.

oh yeah, the other strange thing is that the part in the code that 
scans the cookie jar has no problems at all. it finds all the cookies
in there. 

thanks in advance,
watson

here is the code:
*****************
use LWP::UserAgent;
use HTTP::Cookies;

$ua = new LWP::UserAgent;

$cookie_jar = HTTP::Cookies::Netscape->new(
                   File     => 'C:\Program
Files\Communications\Netscape\Users\me\cookies.txt',
                   #AutoSave => 1,
               );
$ua->cookie_jar($cookie_jar);

@requests = ('http://somehost');
#********************
sub makerequest {

#what to get
$download_link = shift @_;

$req = new HTTP::Request 'GET' => $download_link;
}
#******************
$count = 1;
foreach (@requests) {

open (OUT, ">cookie_results_" . $count . '.html') or die "Can't open output
for writing\n";
$count++;

#current cookie status
print OUT "<hr><h2>State of the Cookie Jar:</h2>";
 sub cookie_scan_cb {        # call back
       [here I print out scan callback parameters]
  }

  $cookie_jar->scan( \&cookie_scan_cb); 

#construct the request
&makerequest($_);

# send request
$res = $ua->request($req);

# check the outcome
if ($res->is_success) {
   print OUT $res->content;
} else {
   print OUT "Error: " . $res->status_line . "\n";
}

close (OUT);
}

Reply via email to