Hello,
I am using template toolkit to generate dynamic content and I was
wondering if there is any way to set a cookie after returning OK. Here
is what I mean.
1-There are two scripts that check for access privileges of a user. One
sets two cookies and the other (mine) sets three cookies.
2- My script checks for all the cookies and if it does not find the
third one it should set it. But the catch is here:
package some_package;
# apache packages
use vars qw($r);
sub handler{
$r = Apache::Request->new(shift);
#code here
$object->{is_allowed_todo} = \&is_allowed_todo;
$template = Template->new();
$remplate->process($file,$object);
return OK;
}
sub is_allowed_todo
{
my ($args) = shfit;
# args are the arguments that I get from my .html file
# [% is_allowed_todo('<A HREF="....>' %]
my $status = __PACKAGE__->SUPER::is_allowed_todo($r);
if ($status)
{
# do this
}
else
{
# do that
}
}
1;
# The SUPER
package some_other;
sub is_allowed_todo
{
my $r = shift;
my $cookies = Apache::Cookie->new($r)->parse();
my @webaccess = $cookies->{'webaccess'} ?
$cookies->{'webaccess'}->value() : ();
unless ($webaccess[MIS_APPS::RHS::Constants::ONE()]);
{
my $user =
$cookies->{'webuname'}->value();
my $job = $cookies->{'webjob'}->value();
($code,$status,$dept) = get_userinfo($user,$job);
Apache::Cookie->new( $r,
-name => 'webaccess',
-value => {
'department'
=> $dept,
'access'
=> $status,
},
-domain => '.rhythm.com',
-expires => '+24h',
-path => '/'
)->bake;
}
return $status;
}
But my problem is that I have already returned OK in my handler. How can
I set another cookie when I have already opened the data stream to the
client browser? I hope I have been clear... :)
Any comments will be greatly appreciated.
-r