[cgiapp] Changing CGI::Session name within a CGI::Application

Mark Knoop mark at rawcane.net
Wed Feb 6 07:16:26 EST 2008


Hi

I am trying to use the CGI::Application::Plugin::Session but I am getting a 
bit confused with what objects are what.

In my cgiapp_init method I have the following:

CGI::Session->name('lsid');
$self->session_config(
       CGI_SESSION_OPTIONS => [ "driver:File", $self->query, { 
Dir=>$session_path  } ],
       DEFAULT_EXPIRY      => '+5m',
       SEND_COOKIE         => 0,
);

Then in my cgiapp_prerun I use

my $session = $self->session;

unless ( $self->session->param('rsid') ) {
    $self->session->param('rsid', 'SOME_VALUE');
    # some code to change prerun mode to redirect to external site
}

and then use $self->session->id as the value to lsid param in a callback url 
which I pass to an external app that I then redirect to
so that when they redirect back with the lsid param in the query string it 
will use that as the session id.

For some reason it is not picking up the session data correctly ie it is 
acting as if rsid in the session data does not exist and redoing the 
redirect though I can't tell whether it is because it is not automatically 
using the lsid param (which is definitely there) or whether it is not 
creating the session successfully in the first place.

It is going to be tricky to create a working example because of the 
redirects but is there anything that I am obviously approaching in the wrong 
way or any obvious errors?

Is there a way I test to see whether $self->session is creating a new 
session or picking up an existing one or not working at all?

Cheers
Mark
 



More information about the cgiapp mailing list