Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: LWP::UserAgent and Cookies

by jczeus (Monk)
on Oct 27, 2021 at 08:37 UTC ( [id://11138099]=note: print w/replies, xml ) Need Help??


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

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?

Replies are listed 'Best First'.
Re^4: LWP::UserAgent and Cookies
by hippo (Bishop) on Oct 27, 2021 at 09:06 UTC

    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://11138099]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-24 06:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found