[tpm] WWW::Mechanize and setting cookies
adam.prime at utoronto.ca
adam.prime at utoronto.ca
Thu Jul 31 16:06:34 PDT 2008
Quoting Madison Kelly <linux at alteeve.com>:
> Hi all,
>
> I've run into the need to set some cookies for a WWW::Mechanize
> object I am using. As I understand it, the default 'cookie_jar' is
> supposed to be an instance of HTTP::Cookies, but I can't see where that
> is implemented in the module. Despite that, I tried calling the
> 'set_cookie' method but, as I expected, got an error saying that is not
> a known method.
>
> So dear TPM, can someone clue me in on how to set a bunch of cookies
> using WWW::Mechanize?
Looking at the documentation it looks like Mechanize is designed such
that it will keep track of cookies that get set through a series of
requests. It looks to me like the only way to set it up to start with
cookies in the first place would be to Create an instance of
HTTP::Cookies with the stuff you want in it, and use that when you
create your initial Mechanize object.
> Bonus round!
>
> If this is an HTTP::Cookies object, what pray tell is '$version'
> supposed to be when setting the cookie? Beyond setting it, there is no
> mention of it in the docs and the code merely shows it being set to '0'
> in undef.
>
> Thanks as always!
Looking at the code it seem to put "\$Version=$version" into your
cookie if you set it to a value larger than 0. I have no idea what
that's about, but i'd probably be passing in 0's.
The interface for HTTP::Cookies looks pretty horrid :x
Adam
More information about the toronto-pm
mailing list