I'm trying to write a filter using modperl that will update parts of the
server response on the fly. My first attempt was to rewrite the path setting
in the server's set cookie response to set the path to: path=/NewPath. After
copying and pasting some examples I came up with the following:
package Apache2::RewriteCookiePath;
use strict;
use warnings;
use Apache2::Filter ();
use Apache2::RequestRec ();
use APR::Table ();
use Apache2::Const -compile => qw(OK);
use constant BUFF_LEN => 1024;

sub handler {
my $f = shift;

while ($f->read(my $buffer, BUFF_LEN)) {
   $buffer =~ s/path=\//path=\/NewPath/g;
   $f->print($buffer);
}

return Apache2::Const::OK;
}
1;

I have not been able to get this code to work. How can I call this code from
a virtual host's config file so that it applies to all cookies set, no
matter what subdirectory is requested? This is my first attempt with
mod-perl, so any pointers would be really helpful.

Thanks

Reply via email to