Seems like I have spent more time on C::A::P::Session than all the other
plugins combined--and I just can't get it to work. It is setting a session
in cgiapp_postrun after logging in for the first time (it is also setting
a cookie very nicely). This is evidenced by the line: 'logged_in: 1" in my
debug2.txt file and the visual setting of the cookie.
However, when I come return from the next HTML page to execute another
runmode, the session is coming up empty. This is evidenced by the line:
'logged_in: ' in my debug1.txt file.
In good olde CGI::Session, I have to use the session id to retrieve the
session:
my $session_id = cookie('CGISESSID');
my $session = new CGI::Session("driver:File", $session_id,
{Directory=>'/tmp'});
I see that an id is created in the cookie by C::A::P::S, but how is it use
to retrieve the session, if at all? Here's my bare bones code:
sub cgiapp_init {
my $self = shift;
$self->session_config(
CGI_SESSION_OPTIONS => [ "driver:File", $self->query,
{Directory=>'/tmp'} ],
DEFAULT_EXPIRY => '+15m',
COOKIE_PARAMS => { -name => 'designsoft',
-path => '/'},
SEND_COOKIE => 1);
open (DEBUG, ">debug1.txt") or die "debug error: $!";
print DEBUG "logged_in:". $self->session->param('logged_in')."\n"; close
DEBUG;
}
sub cgiapp_prerun {
if ($self->session->param('logged_in')) { # if logged in then grab
the rest of the session
$user_name = $self->session->param('user_name');
$user_id = $self->session->param('user_id');
} elsif ($query->param('rm') eq "li") { #If attempted to log in
$self->prerun_mode('li'); # run log-in mode
} else { #If not logged in
$self->prerun_mode('sl'); # then show form
}
}
sub cgiapp_postrun {
my $self = shift;
$self->set_session(); #set the session
}
sub set_session {
my $self = shift;
$self->session->param(user_name => $user_name);
$self->session->param(user_id => $user_id);
$self->session->param(logged_in => 1); #persistent
open (DEBUG, ">debug2.txt") or die "debug error: $!";
print DEBUG "logged_in:". $self->session->param('logged_in')."\n"; close
DEBUG;
}
---------------------------------------------------------------------
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]