Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: CGI::Session problems

by ropey (Hermit)
on Mar 05, 2002 at 18:33 UTC ( [id://149464]=note: print w/replies, xml ) Need Help??


in reply to CGI::Session problems

I may be wrong, but I once had a similar problem. When creating your hidden field such as
$Session->param(-name=>'age', -value=>$age);
it won't actually change the value as it is already initialised. try
$Session->param(-name=>'age', -value=>$age, -force => 1);
which now updates the value. HTH

Replies are listed 'Best First'.
Re: Re: CGI::Session problems
by fuzzyping (Chaplain) on Mar 05, 2002 at 19:47 UTC
    Thanks, but that didn't seem to help as much as I'd hoped. I tried to force the save to $Session->param('age'), but now it loses 'name', forcing it to default to ++0, or 1. The result would be to return the correct name and ++$age after the first submit, but "'s new age is 1" and "'s new age is 2" for the subsequent submits. Anything after that continues to repeat the last result.

    Sensing that my hidden data isn't being passed after the 2nd invocation (isn't that what CGI::Session is for???), I made the following changes to &add_age to try and get it to force 'name' as well...
    sub add_age { my $age = $Session->param('age'); my $name = $Session->param('name'); ++$age; print $Session->param('name'), "\'s new age is $age"; $Session->param(-name=>'age', -value=>$age, -force=>1); $Session->param(-name=>'name', -value=>$name, -force=>1); $Session->save_param($cgi); print $cgi->start_form, $cgi->hidden(-name=>'test', -value=>'test'), $cgi->submit('Next'), $cgi->end_form; }
    While it now saves the name correctly, it doesn't increment at all past the first good invocation. How do the CGI gods handle this type of ongoing, looping CGI type? Am I assuming incorrectly in that CGI::Session stores full session state information in the db file? As long as it knows my $sid, and I load it correctly, shouldn't the hidden data always be available to me?

    *sigh*

    -fuzzyping

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://149464]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-20 03:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found