<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Mark Stosberg</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/mark_stosberg/" />
    <link rel="self" type="application/atom+xml" href="http://blogs.perl.org/users/mark_stosberg/atom.xml" />
    <id>tag:blogs.perl.org,2009-11-03:/users/mark_stosberg//188</id>
    <updated>2012-08-22T13:49:01Z</updated>
    <subtitle>A blog about the Perl programming language</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.38</generator>

<entry>
    <title>Thanks to Olaf Alders for HTTP::CookieMonster</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/mark_stosberg/2012/08/thanks-to-olaf-alders-for-httpcookiemonster.html" />
    <id>tag:blogs.perl.org,2012:/users/mark_stosberg//188.3723</id>

    <published>2012-08-22T13:44:53Z</published>
    <updated>2012-08-22T13:49:01Z</updated>

    <summary><![CDATA[The old, horrible way, to get a cookie by name with LWP::UserAgent or WWW::Mechanize: my $cookie = $a-&gt;cookie_jar-&gt;{COOKIES}-&gt;{".$SITE_DOMAIN"}-&gt;{'/'}-&gt;{$COOKIE_NAME}; The new way, with HTTP::CookieMonster: my $monster = HTTP::CookieMonster-&gt;new( cookie_jar =&gt; $a-&gt;cookie_jar ); my $cookie = $monster-&gt;get_cookie($COOKIE_NAME); Much better. Thank you. I&#8217;d...]]></summary>
    <author>
        <name>Mark Stosberg</name>
        <uri>http://mark.stosberg.com/</uri>
    </author>
    
    <category term="cookies" label="cookies" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="wwwmechanize" label="WWW::Mechanize" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/mark_stosberg/">
        <![CDATA[<p>The old, horrible way, to get a cookie by name with <code>LWP::UserAgent</code> or <code>WWW::Mechanize</code>:</p>

<pre><code>my $cookie = $a-&gt;cookie_jar-&gt;{COOKIES}-&gt;{".$SITE_DOMAIN"}-&gt;{'/'}-&gt;{$COOKIE_NAME};
</code></pre>

<p>The new way, with <a href="https://metacpan.org/module/HTTP::CookieMonster">HTTP::CookieMonster</a>:</p>

<pre><code>my $monster = HTTP::CookieMonster-&gt;new( cookie_jar =&gt; $a-&gt;cookie_jar );
my $cookie = $monster-&gt;get_cookie($COOKIE_NAME);
</code></pre>

<p>Much better. Thank you. I&#8217;d love to see something like this built right into WWW::Mechanize.</p>
]]>
        

    </content>
</entry>

</feed>
