Thanks for the quick response!

Unfortunatnly, if I use that method the rest of the script still executes and the redirect headers seem to print after the <html></html> tags

<html>
my templated html
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>200 OK</title>
</head><body>
<h1>OK</h1>
<p>The document has moved <a href="my_uri">here</a>.</p>
<hr>
<address>Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.8 mod_perl/2.0.4 Perl/v5.8.8 Server at xxx.xxx.xxx.49 Port 80</address>
</body></html>




Cees Hek wrote:
Hi Brad,

Try moving your code to the prerun stage, and look at the examples in
CGI::Application::Plugin::Redirect.  The first example in the docs is pretty
much what you want:

        use CGI::Application::Plugin::Redirect;
        sub cgiapp_prerun {
            my $self = shift;

            if ( << not logged in >> ) {
                return $self->redirect('login.html');
            }
        }

Cheers,

Cees

On Tue, May 5, 2009 at 2:25 PM, Brad Van Sickle <bvs7...@gmail.com> wrote:

I'm running under mod_perl, not sure if that's relevant here or not... I
think it is because I've been able to get this working in a non-mod_perl
envrionment previously...

I'm attempting to validate a user's session in my cgi::app script.  If the
session cookie is not present, or the session is invalid, I want to redirect
the user to the login module to get authenticated.   The "order of
operations" document has a nice example of how to do this from within init,
but printing out the redirect headers and than issuing a die() to prevent
the rest of the operations from executing.

This does not work for me.  As soon as that die executes my script fails
with the error:

Error executing class callback in init stage: Died at blah blah blah
my code:  if (!$ValidSession)
       {
       use CGI::Application::Plugin::Redirect;
       $self->teardown();
       print $self->redirect($FailureLocation);
      die;
       }

I've read every bit of documentation I can find and tried everything I can
think of... I could really use some suggestions at this point.
Thanks!







#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################



#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################

Reply via email to