Check session variable before delivering cached page

All pages are available only after login. With the obvious exceptions of the login form itself and the action that processes the submitted data, that is what the code below does

if(empty($passengerId) && $controllerName !== "passenger") {
    $controller->redirect('frontend/passenger/login');
}

The customer should be logged in for the time of the session duration. If he/she comes back in a week he/she should log in again. trying to keep it as simple as possible.

thank you for your help