Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^3: Passing a cookie with LWP::UserAgent

by Anonymous Monk
on May 08, 2007 at 13:30 UTC ( #614133=note: print w/replies, xml ) Need Help??

in reply to Re^2: Passing a cookie with LWP::UserAgent
in thread Passing a cookie with LWP::UserAgent

Well, I was trying to do the same thing. Had lots of trouble. Couldn't figure out why until I realized that the file I was trying to initialize wasn't being loaded.
my $ua = LWP::UserAgent->new; $ua->cookie_jar(HTTP::Cookies::Netscape->new('file' => '<your cookie f +ile here>' )); my $url = URI->new( '<your URL here>' ); my $response = $ua->request(HTTP::Request->new(GET => $url));
but the above code works. If you follow other examples, you'll end up creating a seperate "cookie jar" and attaching it to your user agent. Just make sure your cookie file is being read because nothing really lets you know it didn't work (I'm sure there is a status or something, but I didn't get into the details and it didn't die or anything on its own).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://614133]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2021-05-10 07:50 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (105 votes). Check out past polls.