bradcathey has asked for the wisdom of the Perl Monks concerning the following question:
Fellow Monasterians,
I'm having a hard time getting my head around sessions.
Background: using CGI::Application, CGI::Application::Session, and CGI::Application::Redirect on a dedicated Linux server.
Scenerio:
Problem: The session param in Members.pm is undef.
So, what am I not getting/understanding about sessions? Thank you!
File Layout
/opt/myapps/-----+ | | | Super.pm | | | /Acmecorp/---+ | | | Login.pm | | | Members.pm | | /var/www/acmecorp/--+ | home.html | /manage/----+ | login.cgi | members.cgi
Super.pm
package Super; use warnings; use strict; use base 'CGI::Application'; use CGI::Application::Plugin::Redirect; use CGI::Application::Plugin::Session; (my $http_host = $ENV{'HTTP_HOST'}) =~ s/(www.)([a-zA-Z0-9\-\.]+)/$2/ +; $self->session_config( COOKIE_PARAMS => { -name => 'MY_SESSID', -expires => '+8h', -path => '/', -domain => ".".$http_host, }, SEND_COOKIE => 1, );
Login.pm
package Login; use base qw(Super); ****login codes goes here and if successful: ***** $self->session->param( 'member_id' => $member_id ); return $self->redirect('/manage/members.cgi'); # I could pass it with return $self->redirect('/manage/members.cgi?id= +'.$member_id), but clunkier
members.cgi
#!/usr/local/bin/perl -T use lib "/opt/myapps/"; use Acmecorp::Members; my $app = Acmecorp::Members->new(); $app->run();
Members.pm
package Members; use base qw(Super); my $member_id = $self->session->param( 'member_id' ); **** query the DB with the member's id *****
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: CGI::App session params losing values between redirects
by almut (Canon) on Feb 14, 2009 at 18:40 UTC | |
Re: CGI::App session params losing values between redirects
by samtregar (Abbot) on Feb 14, 2009 at 17:15 UTC | |
by bradcathey (Prior) on Feb 14, 2009 at 18:16 UTC | |
by samtregar (Abbot) on Feb 14, 2009 at 21:02 UTC | |
by bradcathey (Prior) on Feb 15, 2009 at 13:53 UTC | |
by samtregar (Abbot) on Feb 15, 2009 at 19:56 UTC | |
Re: CGI::App session params losing values between redirects
by bradcathey (Prior) on Feb 28, 2009 at 19:49 UTC |