Q:

Phalcon Session Timeout show login page

My Phalcon application has a layout with another layout inside of a div element of the main layout.  My problem is that when the session time's out the login form (session/index) appears in the second layout.  Here's a visual and the code that checks if the session is still active.  I know what is happening.  Just can't find a solution that preforms my desired action.  Thanks. 

<? php

use Phalcon\Mvc\Controller;
use Phalcon\Mvc\Dispatcher;

class ControllerBase extends Controller
{
    protected function initialize()
    {
        $this->tag->setTitle('Website | ' .  $this->view->H1Tag);
        $this->flash->output();
    }

    public function beforeExecuteRoute(Dispatcher $dispatcher)
    {
        if (! $this->session->has('auth') && $dispatcher->getControllerName() ! = 'session') {
            $dispatcher->forward(['controller' => 'session', 'action' => 'index']);
            return false;
        }
    }
}

A:

You might have to inject JS in your script: before redirecting to the login page, something like:
<? php echo "<script>window.top.location.href = \"http://www.yourdomain/login\";</script>"; ? >

As a server-side language, PHP can't escape the iframe by itself.