Skip to content

Commit

Permalink
An ordinary print statement is not enough to set the cookie - at leas…
Browse files Browse the repository at this point in the history
…t under mod_perl. So we override the 'save' method of the Cookie module and use the 'add_header' method of CGI::Application instead. This works also under mod_perl
  • Loading branch information
reneeb committed Feb 21, 2011
1 parent dc852ae commit bf6166c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/OTRS/OPR/Web/App.pm
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ sub session {
$self->{___session} = OTRS::OPR::Web::App::Session->new(
config => $self->config,
expire => $expire,
app => $self,
);
}

Expand Down
24 changes: 24 additions & 0 deletions lib/OTRS/OPR/Web/App/Session.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,33 @@ sub new{
$self->_config( $args{config} );
$self->expire( $args{expire} );

$self->app( $args{app} );

{
no warnings 'redefine';
*ReneeB::Session::State::Cookie::save = sub {
my ($session,$id) = @_;

my $cookie = CGI::Cookie->new(
-name => $session->cookiename,
-value => $id,
-expire => $session->expire,
);

$self->app->header_add( -cookie => $cookie );
};
}

return $self;
}# new

sub app {
my ($self,$value) = @_;

$self->{__app__} = $value if @_ == 2;
return $self->{__app__};
}

sub session{
my ($self) = @_;

Expand Down
2 changes: 1 addition & 1 deletion lib/ReneeB/Session/State/Cookie.pm
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ sub delete{
print "Set-Cookie: $cookie\n";
}

1;
1;

0 comments on commit bf6166c

Please sign in to comment.