The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

HTTP::Cookies::PhantomJS - read and write PhantomJS cookies file

SYNOPSIS

        use strict;
        use HTTP::Cookies::PhantomJS;
        use WWW::Mechanize::PhantomJS;
        use LWP::UserAgent;
        
        my $phantom = WWW::Mechanize::PhantomJS->new(cookie_file => 'cookies.txt');
        $phantom->get('https://www.google.com/');
        
        my $lwp = LWP::UserAgent->new(cookie_jar => HTTP::Cookies::PhantomJS->new(file => 'cookies.txt'));
        # will reuse cookies received by PhantomJS!
        $lwp->get('https://www.google.com/');

DESCRIPTION

This is just HTTP::Cookies subclass, so it has all same methods, but reloads load() and save() to make available reading and writing of PhantomJS cookies file. You can easily transform (if you need) HTTP::Cookies object to HTTP::Cookies::PhantomJS or vice versa by reblessing (dirty way) or with code like this:

        use strict;
        use HTTP::Cookies;
        use HTTP::Cookies::PhantomJS;
        
         my $plain_cookies = HTTP::Cookies->new;
         # fill it with LWP or other way
         ....
         # transform
         my $phantom_cookies = HTTP::Cookies::PhantomJS->new;
         $plain_cookies->scan(sub {
                $phantom_cookies->set_cookie(@_);
         });

SEE ALSO

HTTP::Cookies

AUTHOR

Oleg G, <oleg@cpan.org>

COPYRIGHT AND LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself