用于后台登录验证
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; } }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。