logo       

Re: Manually adding cookies to WWW::Mechanize's in-memory cookie jar: msg#00038

Subject: Re: Manually adding cookies to WWW::Mechanize's in-memory cookie jar
Hi Chris,

Just create a cookie jar of your own, then pass it into $mech at creation time.

my $cj = HTTP::Cookies->new();
my $mech = WWW::Mechanize->new ( cookie_jar => $cj )

The name cookie_jar is documented, so you can probably safely use the cookie jar that $mech creates for you.

Cheers,
Peter



Christopher Hart wrote:

Thanks Peter.  What I'm having trouble with is finding how to get
access to the cookie jar that WWW::Mechanize maintains.  I'm familiar
with using HTTP::Cookies with LWP and manually creating cookies, but I
can't find how/where the Mechanize module makes this object available
through its interface. Do you have any ideas on that?  Any help is
appreciaed.

Thanks!

On 6/18/06, Peter Stevens <peter.stevens@xxxxxxxxxx> wrote:


 Hi Chris,

 From
http://search.cpan.org/~gaas/libwww-perl-5.805/lib/HTTP/Cookies.pm
(HTTP::Cookies):

 $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". Googling for cookie_jar->set_cookie produces a
few hundred pages - one of them should do ;-)

 Cheers,

 Peter



 Christopher Hart wrote:
Hello,

 I need to simulate some JavaScript that creates a cookie using
 WWW::Mechanize.  How can I programmatically add a cookie to the
 in-memory cookie jar?  I searched around for some examples on this,
 but wasn't able to find anything.

 Any help is appreciated.  Thanks!

 Chris



--
----------------------------------------------------------------------
Peter Stevens The Free Cell Phone Monitoring Service
 www.MinuteWatcher.com




--
----------------------------------------------------------------------
Peter Stevens                   The Free Cell Phone Monitoring Service
www.MinuteWatcher.com



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe