bradcathey has asked for the wisdom of the Perl Monks concerning the following question:
Fellow Monasterians
I've spent the last few hours exploring CGI::Application::Plugin::Session and have run into a question of how to access session params by the name of the session.
I was able to get it working with straight CGI::Session:
use CGI::Session; #initial trip to server CGI::Session->name("SESSION_ID1"); my $session = new CGI::Session(); $session->param('user' => 'Fred'); print $session->header(); #subsequent trip CGI::Session->name("SESSION_ID2"); my $session = new CGI::Session(); $session->param('user' => 'Barney'); print $session->header(); #later... CGI::Session->name('SESSION_ID1'); my $session = new CGI::Session(); my $user_A = $session->param('user'); CGI::Session->name('SESSION_ID2'); my $session = new CGI::Session(); my $user_B = $session->param('user'); print "Content-type: text/html\n\n"; print $user_A."<br />"; print $user_B";
But when I try:
#first trip $self->session_config( DEFAULT_EXPIRY => '+8h', COOKIE_PARAMS => { -name => 'SESSION_ID1', -expires => '+8h', -path => '/', }, SEND_COOKIE => 1, ); $self->session->param('user' => 'Fred'); #later trip $self->session_config( DEFAULT_EXPIRY => '+8h', COOKIE_PARAMS => { -name => 'SESSION_ID2', -expires => '+8h', -path => '/', }, SEND_COOKIE => 1, ); $self->session->param('user' => 'Barney');
I can't figure out if there is a short cut to return:
print $self->session->param('user');
based on the name of the session. Am I stuck with using
CGI::Session->name('SESSION_ID1'); my $session = new CGI::Session(); my $user_A = $session->param('user'); CGI::Session->name('SESSION_ID2'); my $session = new CGI::Session(); my $user_B = $session->param('user');
? Or is there some cool way with CAP::Session that I'm missing? Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is it possible to have 2 CAP::Sessions?
by friedo (Prior) on Jul 06, 2008 at 00:30 UTC | |
by bradcathey (Prior) on Jul 06, 2008 at 01:16 UTC | |
|
Re: Is it possible to have 2 CAP::Sessions?
by bradcathey (Prior) on Jul 06, 2008 at 13:08 UTC | |
by friedo (Prior) on Jul 06, 2008 at 22:29 UTC |