[TriLUG] Perl HTTP cookies expert question
William Sutton
william at trilug.org
Tue Jan 31 12:20:09 EST 2006
Synopsis: I'm trying to use HTTP cookies using CGI::Application and
either Apache::Cookie or Apache2::Cookie on Apache 2 with mod_perl 2.
Problem: Error messages of various types
Details:
1. I'm syslog'ing all my Perl code debug messages
2. I have a CGI::Application program that does some minimal trivial things
3. I have it running on Gentoo under Apache 2/mod_perl 2
4. The foregoing configuration works
5. I want to set an HTTP cookie, but I would prefer to do it in OO
fashion, rather than using CGI::Cookie to set header_props (discouraged in
the current CGI::Application documentation in favor of OO)
Solution 1: Apache::Cookie
- sample code:
use strict;
use base CGI::Application;
use CGI::Application::Plugin::Apache qw(:all);
use Apache::Cookie;
sub setup
{
my $this = shift || {};
my $q = $this->query();
my $cookie = Apache::Cookie->new($q, name => "foo");
# ... line above causes code to fail
}
- error:
[Tue Jan 31 12:13:47 2006] [error] [client 127.0.0.1] Can't locate object
method "new" via package "Apache::Cookie" at Demo.pm line 56.
Solution 2: Apache2::Cookie
- sample code:
use strict;
use base CGI::Application;
use CGI::Application::Plugin::Apache qw(:all);
use Apache2::Cookie;
sub setup
{
my $this = shift || {};
my $q = $this->query();
my $j = Apache2::Cookie::Jar->new($q);
# ... line above causes code to fail
}
- error:
[Tue Jan 31 12:11:13 2006] [error] [client 127.0.0.1] /usr/bin/perl:
symbol lookup error: /usr/lib/perl5/vendor_perl/5.8.7/i686-linux/auto/APR/Request/Apache2/Apache2.so:
undefined symbol: modperl_xs_sv2request_rec
Comments:
- both sets of code were constructed according to documentation found
online (pod2html from the modules, stored on CPAN or other sites)
- both sets of code theoretically ought to work
- clearly, they don't
I'm rather at wits' end, having been beating on this in different
permutations for a couple of days. FWIW my recollection is that I also
tried CGI::Cookie, to no effect, but that's just recollection, so might be
wrong...it's been a couple of days....
I would appreciate any help available, since I want to do this the Right
Way (TM) (HTTP), not the Expedient Way (TM) (JavaScript)
--
William Sutton
More information about the TriLUG
mailing list