You may have a typo in the code provided.  Also, you should probably start
using mod_perl methods rather than perl built-in functions.

> In a PerlAccessHandler I have code similar to the following:
> 
> sub handler
> {
>     my $r = shift;
>     my ($cgi, $cookie);
> 
>     use CGI;
>     $cgi = new CGI;
>     $cookie = $cgi->cookie(-name => 'test');
> 
>     # For debugging only
>     open(TEST, ">>/tmp/accesstest");
>     flock(TEST,2);
>     print TEST "cookie = $cookie";
>     close(test);
> 

This should certainly be something like:

my $log = $r->log();
$log->debug("cookie = $cookie");

which would log to the apache error log (with LogLevel set to debug in
httpd.conf).  Did you mean to close TEST instead of test?

>     # This if block is not included in the PerlHandler version
>     if ($cookie eq '')
>     {
>         return FORBIDDEN;
>     }

Still need to return something here!

return OK;

> }
> 
> However, nothing is written to the log file and the forbidden 
> screen is
> displayed. The exact same code works fine if its in a regular 
> mod_perl module
> installed using PerlHandler. Why is the code working inside a 
> PerlHandler
> module and not in PerlAccessHandler?
> 

PerlHandler's don't require a return value (although it's best to do so in
case you want to chain several of them together).  PerlAccessHandler's must
return OK, FORBIDDEN or DECLINED.

Hope that helps,

Chris

Reply via email to