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!

—Brad
"The important work of moving the world forward does not wait to be done by perfect men." George Eliot

In reply to Is it possible to have 2 CAP::Sessions? by bradcathey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.