I have a perl script where after fetching a page I need to add a cookie to an already existing cookiejar with cookies in it already. how do I go about doing this? I'm hoping for a python mechanize style .set_cookie() function
views:
50answers:
1
+4
A:
A WWW::Mechanize object isa LWP::UserAgent, which has a cookie_jar
attribute that normally contains a HTTP::Cookies object, which has a set_cookie
method.
So you'd do something like:
$mech->cookie_jar->set_cookie( $version, $key, $val, $path, $domain, $port,
$path_spec, $secure, $maxage, $discard, \%rest )
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".
cjm
2010-09-02 02:28:56
testing it out thanks!
Joe Schmoe
2010-09-02 02:32:47