我的Phalcon应用程序的布局在主布局的div元素内具有另一个布局。我的问题是,当会话时间不足时,登录表单(会话/索引)会出现在第二个布局中。这是一个可视化代码,它检查会话是否仍处于活动状态。我知道发生了什么事。只是找不到能够执行我想要的操作的解决方案。谢谢。
<?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;
}
}
}
答案 0 :(得分:0)
您可能必须在脚本中注入JS:在重定向到登录页面之前,像这样:
<?php echo "<script>window.top.location.href = \"http://www.yourdomain/login\";</script>"; ?>
作为服务器端语言,PHP本身无法逃避iframe。