setting cookies (mod_perl)


U

un

I'm trying to learn mod_perl 2

I've created the following script:
package smmod;

use strict;
use warnings;

use Apache::RequestRec ();
use Apache::RequestIO ();
use Apache::Const -compile => qw(OK);

sub handler {
my $r = shift;
$r->headers_out->add('Set-Cookie' => 'myCookie=vanilla'); # BUG ?
$r->content_type('text/plain');
$r->print("Hello");
return Apache::OK;
}
1;

And I've added the following to my apache conf file:
PerlModule smmod
<Location /sm>
SetHandler modperl
PerlResponseHandler smmod
</Location>

Yet I keep getting this error when I use the script:
[Thu Oct 14 19:42:56 2004] [error] [client XXXX] Can't locate object method
"add" via package "APR::Table" at C:/Program Files/Apache
Group/Apache2/lib/perl/smmod.pm line 13.\n

It's probably simple, but I'm not able to figure out what's wrong. Anybody?

Thanks in advance
 
Ad

Advertisements

B

Brian McCauley

un said:
$r->headers_out->add('Set-Cookie' => 'myCookie=vanilla'); # BUG ?
Yet I keep getting this error when I use the script:
[Thu Oct 14 19:42:56 2004] [error] [client XXXX] Can't locate object method
"add" via package "APR::Table" at C:/Program Files/Apache
Group/Apache2/lib/perl/smmod.pm line 13.\n

It's probably simple, but I'm not able to figure out what's wrong. Anybody?

Try

require APR::Table;

or

use APR::Table ();

The mod_perl module often creates objects of classes for which it has
not (full) loaded the methods.

I've never really know why the mod_perl docs use use() rather then
require().
 
B

Ben Morrow

Quoth "un said:
I'm trying to learn mod_perl 2

I've created the following script:
package smmod;

Packages with all-lowercase names are reserved for Perl pragmas. I would
suggest using something else; I would also suggest not using a
top-level namespace but putting it somewhere appropriate ('Writing
modules is easy. Naming modules is hard' [Anno Siegel, c.l.p.m])

Ben
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top