使用Hook时出错: -
我已经完成了 $ config ['enable_hooks'] = TRUE;在autoload.php中并设置加密密钥..
配置/ Hook.php
$hook['pre_controller'] = array(
'class' => 'Login_hook',
'function' => 'check_login_hook',
'filename' => 'Login_hook.php',
'filepath' => 'hooks'
);
钩/ Login_hook.php
<?php
class Login_hook extends CI_Controller{
function check_login_hook(){
if(isset($this->session->userdata['user_storage'])){
echo $user_id=$this->session->userdata['user_storage']['s_u_id'];
echo $user_id=$this->session->userdata['user_storage']['s_u_name'];
}else{
echo "n";
}
}
}
?>
错误是: -
Unable to locate the specified class: Session.php
答案 0 :(得分:0)
在构造
中加载库会话class check_login_hook extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->library('session');
}
在applications / config / autoload.php
中打开autoload.php$autoload['libraries'] = array('session');
答案 1 :(得分:0)
在
中打开config.php$config['base_url'] ='your base url';
还在autoload.php中启用帮助程序类
$autoload['helper'] = array('url');