Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Re: LWP::UserAgent and Cookies

by IlyaM (Parson)
on Dec 12, 2001 at 03:54 UTC ( [id://131111]=note: print w/replies, xml ) Need Help??


in reply to Re: LWP::UserAgent and Cookies
in thread LWP::UserAgent and Cookies

Just a note:

You don't need

$cookie_jar->extract_cookies( $response );
If cookie jar object is set for user agent object than user agent does this itself.

--
Ilya Martynov (http://martynov.org/)

Replies are listed 'Best First'.
Re^3: LWP::UserAgent and Cookies
by jczeus (Monk) on Oct 27, 2021 at 08:37 UTC
    This is a very old thread, but having just tried myself I noticed that the cookie is not set if I don't make that method call.

    Although not needed in my example, I used a file for saving the cookie just to check the session-ID, and the file stayed empty without that call. Any thoughts?

      This works fine for me:

      #!/usr/bin/env perl use strict; use warnings; use LWP::UserAgent; use HTTP::Cookies; use Test::More tests => 1; my $cookie_jar = HTTP::Cookies->new; my $ua = LWP::UserAgent->new; $ua->cookie_jar ($cookie_jar); my $response = $ua->get ('https://twitter.com/'); like $cookie_jar->as_string, qr/guest_id=/, 'Cookie retrieved';

      HTTP::Cookies 6.01, LWP::UserAgent 6.15.


      🦛

        For some strange reason, works now for me too. Probably a PEBKAC. Thank you for your help.

        HTTP::Cookies 6.10, LWP::UserAgent 6.55.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-04-24 07:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found