convert netscape cookies to LWP perl

849 Views Asked by At

I am trying to convert cookies in Netscape format that were exported from firefox to LWP format to use them in another library that wants cookies only in LWP format. I am using this script

#!/usr/bin/perl

use LWP;
use HTTP::Cookies;
use Data::Dumper;

my $in =  'cookies.txt';
my $out = 'cookies.lwp';
my $c = HTTP::Cookies::Netscape->new;
$c->load($in);
print Dumper($c);
$c->HTTP::Cookies::save($out);

exit;

But I am getting empty LWP cookie file, and Dumper prints

$VAR1 = bless( {
                 '' => 'cookies.txt',
                 'COOKIES' => {}
               }, 'HTTP::Cookies::Netscape' );

Why HTTP:Cookies cant read my cookies file in Netscape format?

1

There are 1 best solutions below

0
On

With this extension I have exported cookies and everything got converted correctly:

https://addons.mozilla.org/en-us/firefox/addon/export-cookies/