Forum Moderators: coopster & phranque

Message Too Old, No Replies

$cookie_jar question

manually set cookies in LWP::UserAgent

         

affter333

4:41 am on Oct 30, 2004 (gmt 0)



I need to manually set 2 cookies
(user=apple) (pass=123) for .yahoo.com

I'm kind of new, so I looked up the cookbook
but don't understand the values
What are $version? $key? $val? $discard?

can someone give an example?
Thanks for your kind help...:)

$cookie_jar->set_cookie($version, $key, $val, $path, $domain, $port, $path_spec, $secure, $maxage, $discard, \%rest)

jollymcfats

4:57 pm on Oct 30, 2004 (gmt 0)

10+ Year Member



Most of the options come right from the Netscape cookie spec, which explains how the browser will react to them. The spec is linked in the perldoc for HTTP::Cookies. The HTTP::Cookies "key" is "NAME" in the spec.

$version isn't well documented. You probably just want to use

1
. If $discard is true, the cookie will be deleted instead of set.

If you're working on a scraper sort of thing, you should set the values in set_cookie() the same way that the site does when it issues the cookie. You can snoop on the Set-Cookie headers either with LWP and some coding, or you could do something like log in with FireFox and view the reponse headers with the WebDev extension.