LWP::UserAgent uses HTTP::Cookies to create cookies. HTTP::Cookies has 4 ways for you to load a cookie:
1. Load it from an LWP-format file, a format known as "Set-Cookie3". This is impractical, since the format is not documented anywhere that I can find.
2. Set it using HTTP::Cookies->set_cookie( $version, $key, $val, $path, $domain, $port, $path_spec, $secure, $maxage, $discard, \%rest ). The documentation says,
"The set_cookie() method updates the state of the $cookie_jar. The $key, $val, $domain, $port and $path arguments are strings. The $path_spec, $secure, $discard arguments are boolean values. The $maxage value is a number indicating number of seconds that this cookie will live. A value <= 0 will delete this cookie. %rest defines various other attributes like "Comment" and "CommentURL".
To use this, I would need to know what the arguments $path_spec and $discard mean, what $version should be set to, and what to set $port to if I want the cookie to work for any port, as cookies generally do.
3. Create the cookie in Firefox and load it from the resulting Netscape-format file. This is impossible, since Firefox and Chrome now both store cookies in sqlite.
4. Create a Netscape cookie by hand in a file, using the file format given here: http://www.cookiecentral.com/faq/#3.5
Then load this in like so: my $cookieJar = HTTP::Cookies::Netscape->new(file => 'cookies.netscape');
When I do this, with the file
where \t is a tab, I get the error message.foo.net\tTRUE\t/\tFALSE\t1755828131\tcookie_name\ttrue
cookies.netscape does not look like a netscape cookies file at /usr/li +b/perl5/site_perl/5.14/HTTP/Cookies/Netscape.pm line 21, <FILE> line +1.
How do you create a cookie to use with LWP::UserAgent?
In reply to Cannot create a cookie using HTTP::Cookies by shagbark
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |