Home  >  Article  >  Backend Development  >  tp3.2.3控制器继承有关问题-搞不懂

tp3.2.3控制器继承有关问题-搞不懂

WBOY
WBOYOriginal
2016-06-13 12:20:271367browse

tp3.2.3控制器继承问题-搞不懂
比如要登录验证,我以前用的时候TP3.1.2的版本,直接新建立一个conn控制器的类,然后用这个conn类继承action类,这个conn类用_initialize(){}  来实现验证设置,如果没有session则调整到login控制器来登录,其他需要验证的类就继承 ConnAction.class的类,但是在3.2.3这个版本我不知道怎么用了,就找到一个了前置控制方法 _before_index() 但是这个方法只能在单独一个控制器里面使用,怎么样全局都使用呢?
------解决思路----------------------
做一个判断登录与否的类 继承 Controller  其他方法再继承 你的这个类
然后有一个登录的页面 也是继承 Controller 

类似


class BaseController extends Controller
{

public function _before_index()
{
if (session('?userid') == FALSE
------解决思路----------------------
session('?username') == FALSE) {
$this->redirect('/index.php/Home/Login/index');
exit;
} else {
}


}

}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn