用于后台登录验证
post_controller_constructor
<?php class Auth { private $CI; private $loginUri = ‘welcome/login‘; private $loginAuth = FALSE; private $sessId = null; public function __construct(){ $this->CI = &get_instance(); $this->CI->load->helper(‘url‘); $this->initSession(); $this->setLoginAuth(); } public function initSession(){ if(session_status()===1){ session_name(SESS_NAME); if($this->sessId!==null){ session_id($this->sessId); } $lifeTime = 24 * 3600; session_set_cookie_params($lifeTime); session_start(); } } public function setLoginAuth(){ if(!empty($_SESSION[‘admin_user_id‘])){ $this->loginAuth = TRUE; } } public function chkLoginAuth(){ if(!$this->loginAuth && !in_array(uri_string(),array(‘login‘, ‘login/ajaxsub‘))){ redirect($this->loginUri); } return TRUE; } }
本文出自 “水滴石穿” 博客,请务必保留此出处http://liangge.blog.51cto.com/7154562/1957417
原文地址:http://liangge.blog.51cto.com/7154562/1957417