Click to See Complete Forum and Search --> : CGI::session


A_Tame_Lion
04-04-2011, 07:49 AM
Hi Folks,

I'm having some problems storing and accessing data with CGI::session. I am trying to store a value called service_id submitted in a html form in the session.

my $serviceid = $query->param('service_id');
$session->param('service_id', $serviceid);

Then access the $serviceid variable in another script/page:

my $service_id = $session->param('serviceid');
my $serviceDB = ($CSSlogin::sstr . $service_id);

Can't see exactly what I am doing wrong, everything else with session seems to be working ok, anyone have any clues on what I am doing wrong here?

TIA

A_Tame_Lion
04-04-2011, 12:23 PM
I was getting errors about uninitialised variables, but tracking this down and inserting a number in place of those variables lead me to believe that the number that was supposed to be in the variable was not being carried forward by CGI::session into the current script/page.

In my original script I tried:

$session->save_param();

An then all the values carried through into my second script with no problem. However on checking the cookie, I can see an unencrypted password, which isn't ideal. So I tried, as per the instructions on CPAN:

$session->save_param(['service_id']);

To save just the particular field/variable that I wanted to use in the next script, and I now get an error:

Can't call method "param" on unblessed reference at C:/Perl/site/lib/CGI/Session.pm line 361.

Not sure why things are not working as per the CPAN tutorial, anyone else had this problem or know a solution?