【发布时间】:2012-01-16 08:19:07
【问题描述】:
我在重定向时遇到问题。我正在使用威廉姆斯模板库。除了重定向之外,一切都可以找到。用户点击退出按钮后仍可访问主页。这是我的代码:
页面控制器:
class Page extends CI_Controller {
function index()
{
$this->load->helper('form');
$this->template->write_view('header','header');
$this->template->write_view('content','login');
$this->template->write_view('sidebar','sidebar');
$this->template->render();
}
}
家庭控制器:
class Home extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->library('session');
$this->load->model('user_model','check',TRUE);
if(!$this->check->checkUserLogin())
{
redirect('page');
}
}
function index()
{
$this->template->write_view('header','header');
$this->template->write_view('content','home');
$this->template->write_view('sidebar','sidebar');
$this->template->render();
}
}
我已经终止了会话,但是当用户单击“返回”按钮时,仍然可以查看主页。但是如果用户刷新页面,那么代码会按预期工作。
请帮忙
【问题讨论】:
-
CI 似乎没有问题。这是正确的行为,您在注销后单击返回按钮后看到的页面是浏览器缓存的副本。如果此链接有帮助,请告诉我:stackoverflow.com/questions/8004534/avoid-go-back-after-logout
-
这个问题应该也能帮助你走向正确的方向stackoverflow.com/questions/8860953/…
标签: php model-view-controller codeigniter