[cgiapp] Plack::Session and CGI::Application
Rhesa Rozendaal
perl at rhesa.com
Mon Nov 28 08:52:58 EST 2016
Hi Max,
I have a method in my app that creates a plack session like so:
use Plack::Session;
sub session {
my $self = shift;
$self->{__my_plack_session} ||= Plack::Session->new($self->query->env)
}
I can then use it like this:
$self->session->get('login');
Hope that helps,
Rhesa
On 11/27/2016 11:27 PM, max.augsburg at gmx.de wrote:
> Hello all,
>
> I don't know whether I am completely stumped but I didn't get
> Plack::Middleware::Session to work.
>
> My simple PSGI script is as follow:
>
> my $app = sub {
> my $env = shift;
> my $webapp = PLogPSGI->new( QUERY => CGI::PSGI->new($env),
> [bla bla bla]
> 'env' => $env
> }
> );
> $webapp->run_as_psgi();
> };
> builder {
> enable 'Session';
> $app;
> };
>
> and my PLogPSGI module looks for example in cgiapp_prerun as follows:
>
> sub cgiapp_prerun {
> my $self = shift;
> my $current_runmode = shift;
> # initialize the session
> my $q =$self->query;
> my $env = $q->env;
> my $session = $env->{'psgix.session'};
> # Check the Login Status and if the user is logged in, start
> the chosen action
> my $login = $session->get('login');
> unless ($login) {
> $self->prerun_mode('show_login') if ($current_runmode
> ne 'login_cb');
> }
> }
>
> I get the following error:
>
> Error executing class callback in prerun stage: Can't call method
> "get" on unblessed reference at /home/maximilian/public_html/cgi-
> bin/./lib/PLogPSGI.pm line 63. at /home/maximilian/public_html/cgi-
> bin/extlib/lib/perl5/CGI/Application.pm line 2449
>
> If I comment out the cgiapp_prerun lines I can look at the PSGI hash
> $env. $env->{'psgix.session'} is empty...
>
> I saw Ron Savages introduction (
> http://savage.net.au/Perl/html/session.management.with.plack.html )
> But unfortunately it doesn't help me.
>
> Thanks in advance,
> Max
>
> ##### CGI::Application community mailing list ################
> ## ##
> ## To unsubscribe, or change your message delivery options, ##
> ## visit: http://lists.openlib.org/mailman/listinfo/cgiapp ##
> ## ##
> ## Web archive: http://lists.openlib.org/pipermail/cgiapp/ ##
> ## Wiki: http://cgiapp.erlbaum.net/ ##
> ## ##
> ################################################################
>
>
More information about the cgiapp
mailing list