Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Checkbox parameter not being stored in CGI::Session

by Anonymous Monk
on Oct 11, 2014 at 09:35 UTC ( [id://1103482]=note: print w/replies, xml ) Need Help??


in reply to Checkbox parameter not being stored in CGI::Session

I see a few problems

urls are hardcoded ...

debugging via log ... eew

$global_session ... super yuck

random suspicious or die on $! usage not seen in the docs

CGI::Application::Plugin::Session is broken as session_config seems to have no effect

your logic is fudgy, you don't use P/R/G

both collect_data and display_data are the same form, and pretty much the same code, and in both codes you fetch data from the $cgi_query and not from the $session -- this is fudge -- and in both display and collect you save data into session -- display is display

I think having templates and logging and "everything" is confusing you (it confused me), its just a lot of stuff to juggle

You should start with pictures, for example

collectPage presents a form processes form submission if got valid data save data into session redirect via get to displayPage if got invalid data show form again while explaining what data is bad displayPage if session display data from session if no session give link to collectPage

Replies are listed 'Best First'.
Re^2: Checkbox parameter not being stored in CGI::Session
by perlron (Pilgrim) on Oct 13, 2014 at 03:15 UTC
    err. newbie code. ok thank you for pointing these out. will go a long way in my development as a perl developer.

      err. newbie code. ok thank you for pointing these out. will go a long way in my development as a perl developer.

      We've all been there :)

      sub collect_data { my $self = shift; my( $page_data, $errors ) = valiDaaTTTee( $self->query, $validatio +nProfile ) if( $errors ){ return $self->tt_process('collect_data.tt', $errors ); } else { $self->validated_session( $page_data ); return $self->redirect( $self->url_for('display) ); } }

      on success you do a redirect get with a url_for('display') not 'mode2' ... matching names makes make things easier ...

      valiDaaTTTee can be some something you write using Data::FormValidator kinda like CGI::Application::Plugin::ValidateRM

      Want to inspect sessions? If viewing your temp or session directory isn't enough, you can always write a session viewer in your admin.cgi :)

      Now to add sub validated_session { } and sub url_for { } and sub valiDaaTTTee { } ... redirect comes from plugin

        ok. this design above i got to decipher now. it looks semantically really nice. thanks.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-24 02:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found