Influenced by a long thread that I started over the weekend about the
number of run modes "allowed" in an application, I've been breaking my one
large app into several. I have a question about turning control back to
another module.

Typical scenario: The user is initially directed to Login.pm. After
successfully logging in, a home screen is output. From there they can fire
user.cgi and User.pm. Of course, I want to check their log-in status at
the start of the User app, so I check the session. If they timed out, I
want to direct them back to Login.pm.

How do I do that and keep some object in tact?

      $self->prerun_mode('sl');    #show log-in screen
OR
      show_login($self);
OR
      $self->header_type('redirect');
      $self->header_props(-url=>"index.cgi?rm=sl");


Thanks, Brad

BTW: Here's the whole deal (sorry for the length):

******************** index.cgi *******************
#!/usr/local/bin/perl

use lib "cgi-bin/cgiwrap/dsoft/";
use strict;
use Login;

my $log = Login->new();
$log->run();

********************* Login.pm *******************
package Login;

sub setup
{
   my $self = shift;
   $self->start_mode('sh');
   $self->mode_param('rm');
   $self->run_modes(
      'sh'   => 'show_home',
      'sl'   => 'show_login',   #show login screen
      'li'   => 'log_in',
      'lo'   => 'log_out',
      );
}

sub show_login
{
   my $self = shift;
   #...
}

******************** user.cgi *******************
#!/usr/local/bin/perl

use lib "cgi-bin/cgiwrap/dsoft/";
use strict;
use User;

my $user = User->new();
$user->run();

********************* User.pm ********************
package User;
use Login;

sub cgiapp_prerun
{
   my $self = shift;
   if ($self->session->param('logged_in'))
   {
      #do stuff
   }
   else
   {
      $self->prerun_mode('sl');   #show log-in screen
OR
      show_login($self);
OR
      $self->header_type('redirect');
      $self->header_props(-url=>"index.cgi?rm=sl");




---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to