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!
In reply to Is it possible to have 2 CAP::Sessions? by bradcathey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |