我遇到了Session的问题。 我没有在localhost或其他服务器上遇到此问题。只有one.com有这个问题。 会话已定义并设置为指定的会话文件夹,但刷新页面时似乎缺少会话。
登录页码
onError
İndex页码(登录后的下一页)
$submitted = $this->input->post('email');
$admin_logged_in = $this->session->userdata('admin_logged_in');
if($admin_logged_in != true){
if($submitted != ""){
$email = xss_clean($this->input->post('email'));
$password = xss_clean($this->input->post('password'));
$id = $this->Admin_Model->admin_log($email,$password);
if($id == 1){
$user = $this->Admin_Model->get_admin($email);
$data['user'] = $user;
$session_data = array(
'admin_id' => $user->id,
'admin_email' => $user->email,
'admin_logged_in' => true
);
$this->session->set_userdata($session_data);
redirect('admin');
}else{
$data['error'] = array( 'type' => 'error', 'message' => 'Account information is incorrect.');
$this->load->view('admin/login',$data);
}
}else{
$this->load->view('admin/login',$data);
}
}else{
$user_id = $this->session->userdata('admin_id');
$user = $this->Admin_Model->get_admin_id($user_id);
$data['user'] = $user;
$this->load->view('admin/admin_home',$data);
}
会话配置
$admin_logged_in = $this->session->userdata('admin_logged_in');
if($admin_logged_in == true){
$user_id = $this->session->userdata('admin_id');
$user = $this->Admin_Model->get_admin_id($user_id);
$data['user'] = $user;
$this->load->view('admin/admin_home',$data);
}else{
$this->load->view('admin/login',$data);
}
我已经感谢能够找到解决方案的朋友。
答案 0 :(得分:1)
我很久没写信了,但也许我满足其他朋友的需求。
$config['sess_driver'] = 'files';
$config['sess_save_path'] = sys_get_temp_dir();
答案 1 :(得分:0)
您需要将会话保存路径设置为
mysqli
因为您有$config['sess_save_path'] = APPPATH . 'cache/sessions/';
个文件
然后$config['sess_driver']
文件夹权限0700
$autoload['libraries'] = array('session');