Hello again,
I'm trying to understand exactly what postrun allows me to do.
I would like to have it set a new session (via C:P:A:Session) before the
script outputs my .tmpl page. This code produces an error:
"Error executing class callback in postrun stage: Can't call method
'session' on an undefined value at..."
It may have nothing to do with my postrun, but I'm still curious.
Thanks all!
Here's the salient code:
sub cgiapp_init {
my $self = shift;
$self->session_config(
CGI_SESSION_OPTIONS => [ "driver:File", $self->query,
{Directory=>'/tmp'} ],
DEFAULT_EXPIRY => '+15m',
COOKIE_PARAMS => { -path => '/' },
SEND_COOKIE => 1);
}
sub setup {
my $self = shift;
$self->start_mode('sh');
$self->mode_param('rm'); #return $self->forward('other_action');
$self->run_modes(
'sh' => 'show_home',
'sl' => 'show_login', #show login screen
'li' => 'log_in', #attempt login
);
}
sub cgiapp_postrun {
my $self = shift;
set_session();
}
sub show_home {
my $self = shift;
my $template = $self->load_tmpl( 'home.tmpl');
return $template->output;
}
sub set_session {
my $self = shift;
$self->session->param(user_name => $user_name);
$self->session->param(user_id => $user_id);
$self->session->param(admin => $admin);
$self->session->param(logged_in => 1);
}
Brad
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]