我真的是CodeIgniter的新手。
我正在尝试设置一个网站,其中用户必须登录才能查看页面。我来自Java,我采用的是分层的方法。
我的想法是编写我自己的Controller基础:
<?php
class MY_Controller extends Controller
{
function Controller()
{
parent::Controller();
if(!$this->quickauth->logged_in())
{
//they need to login, send them to the login page.
}
}
}
?>现在,我可以编写控制器来扩展它,并且我将确保它们将始终被登录。
以下是登录页面的概要:
<?php
class login extends Controller
{
function index()
{
//Lets just double check, they might not have to login.
if ($this->quickauth->logged_in())
{
//send them to the main controller
}
}
}
?>如你所见,我已经走到这一步了。我需要替换什么:
用什么?
有没有更好的方法来做这件事?
谢谢,布莱克
发布于 2010-12-02 13:35:51
如果你加载'url_helper‘,你有一个重定向函数在里面。有关url helper的更多信息,请阅读文档。
https://stackoverflow.com/questions/4331746
复制相似问题