### Pre-runmode method sub cgiapp_prerun { my $self = shift; my $next_mode = shift; my $q = $self->query(); $self->_get_session(); ### If a login/help runmode, then you're finished... if ($next_mode =~ m/^help_/ || $next_mode =~ m/^login_/ || $next_mode =~ m/^splash_screen_/ ) { return; } ### All other runmodes require that you be logged in... unless ($Session->param("_Is-Logged_In")) { ### Save current runmode and passed parameters so that we can re-invoke it after ### the user gets logged in... $Session->save_param($q); $Session->param("Logged-In-Runmode", $next_mode); $self->prerun_mode("login_form"); } return; } ### Get a session for this invocation sub _get_session { my $self = shift; my $q = $self->query(); $Session = new CGI::Session(undef, $q, {Directory=>"/tmp"}), unless ($Session); $SessionID = $Session->id(); if ($Session->is_new() ) { $Session->expire('+1y'); my $cookie = $q->cookie(-name => "CGISESSID", -value => $SessionID, -expires => '+1y'); $self->header_props(-cookie => $cookie); } }