[cgiapp] Redirecting with CGI::App Problem (possibly mod_perl related)

Cees Hek ceeshek at gmail.com
Fri Jun 5 00:30:04 EDT 2009


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 <bvs7085 at 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://lists.openlib.org/mailman/listinfo/cgiapp    ##
> ##                                                            ##
> ##  Web archive:   http://lists.openlib.org/pipermail/cgiapp/   ##
> ##  Wiki:          http://cgiapp.erlbaum.net/                 ##
> ##                                                            ##
> ################################################################
>
>


More information about the cgiapp mailing list