OK, unable to sort out the CGI::Session::Auth issues I've encountered in my latest module, I wrote the following script in hopes of breaking down the use of the module, making it plain. But this script is showing the same behavior to me that my complicated module is showing. That is to say, that upon submission of my NextForm, and w/o losing my session cookie, I am returned to the login form. Why is this? What, pray tell, am I missing here?

-- Hugh

#!/usr/bin/perl -w use strict; use warnings; use CGI; use CGI::Session; use CGI::Session::Auth; use CGI::FormBuilder; my $q = CGI->new(); my $s = CGI::Session->new(undef,$q,{ Directory => '/tmp' }); my $auth = CGI::Session::Auth->new({ CGI => $q, Session => $s }); $auth->authenticate(); my $html; if($auth->loggedIn){ $html = showSecretPage($html); } else { $html = showLoginPage(); } print $s->header; print $html; print STDERR "Found end of script.\n"; 1; sub showSecretPage { my $html = shift; print STDERR "We are now logged in.\n"; showNextForm($html); } sub showLoginPage { my $form = CGI::FormBuilder->new( name => 'LoginForm', method => 'post', ); $form->field( name => 'userid', label => 'UserID' ); $form->field( name => 'pw', label => 'PassWord', type => 'password' +); my $html; if($form->submitted && $form->validate){ $html = $form->confirm( header => 0 ); $html .= showNextForm(); } else { $html = $form->render( header => 0 ); } return $html; } sub showNextForm { my $form = CGI::FormBuilder->new( name => 'NextForm', method => 'post', ); $form->field( name => 'name', label => 'Name' ); $form->field( name => 'age', label => 'Age' ); my $html; if($form->submitted && $form->validate){ $html .= $form->confirm( header => 0 ); } else { $html .= $form->render( header => 0 ); } return $html; }
if( $lal && $lol ) { $life++; }

In reply to Stumbling through CGI::Session::Auth, what am I missing? by hesco

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.