Hello!

I'm trying to migrate a site over to an Apache2 server from an Apache1 server. The perl cookie handling pieces of code are not quite working. Here's the error I get:

Can't locate object method "fetch" via package "Apache2::Cookie" (perhaps you forgot to load "Apache2::Cookie"?) at /usr/local/apache/htdocs/autohandler line 6.

Our site uses Mason. The block of code causing trouble is below. Per the documentation on CPAN, I added the $r object and changed the name of the packages referenced in the code. When I received the can't locate "fetch" error, I had the server admin check the installation and update the packages again. He insists that Apache2::Cookie is available. Assuming it is, is there anything is this code that would cause the error?

<%init> local *session; if ($r->uri =~ m/product|faq|finder|broadmarket|msp/gi) { my %c = Apache2::Cookie->fetch($r); my $session_id = exists $c{session_} ? $c{session_}->value : undef; eval { tie %session, 'Apache2::Session::File', $session_id, { Directory => '/var/sessions/data', LockDirectory => '/var/sessions/lock', }; }; if ($@) { die $@ unless $@ =~ /Object does not exist/; # Re-throw $m->redirect('/index.html'); } #expires => '+20m', Apache2::Cookie->new( $r, name => 'session_', value => $session{_session_id}, path => '/', )->bake; } #$m->out($r->as_string); $m->call_next; </%init>
Some people are like Slinkies. Not really good for anything, but you still can't help but smile when you see one tumble down the stairs.

In reply to Convert Apache1 perl to Apache2 by darkwater23

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.