0
좋은 하루 휄로우.Codeigniter 로그인 세션 알 수없는 오류
내 CMS 로그인에 문제가 있습니다. 로그인 버튼을 클릭하면 로그인 페이지가 새로 고침되고 다시 나타납니다. 세션 라이브러리가 정의되어 있습니다. 세션 암호화 키가 설정됩니다.
로그인 컨트롤러 코드는 다음과 같습니다
<?php
class User extends Admin_Controller {
public function __construct(){
parent::__construct();
}
public function login(){
$dashboard = 'admin/dashboard';
$this->user_m->loggedin() == FALSE || redirect($dashboard);
$rules = $this->user_m->rules;
$this->form_validation->set_rules($rules);
if ($this->form_validation->run() == TRUE) {
// We can login and redirect
if ($this->user_m->login() == TRUE) {
redirect($dashboard);
}
else {
$this->session->set_flashdata('error', 'That email/password combination does not exist');
redirect('admin/user/login', 'refresh');
}
}
$this->data['subview'] = 'admin/user/login';
$this->load->view('admin/_layout_modal', $this->data);
}
public function logout(){
$this->user_m->logout();
redirect('admin/user/login');
}
}
로그인 모델 코드는 다음과 같습니다
<?php
class User_M extends MY_Model
{
protected $_table_name = 'users';
protected $_order_by = 'name';
public $rules = array(
'email' => array(
'field' => 'email',
'label' => 'Email',
'rules' => 'trim|required|valid_email|xss_clean'
),
'password' => array(
'field' => 'password',
'label' => 'Password',
'rules' => 'trim|required'
)
);
function __construct()
{
parent::__construct();
}
public function login()
{
$user = $this->get_by(array(
'email' => $this->input->post('email'),
'password' => $this->hash($this->input->post('password')),
), TRUE);
if (count($user)) {
// Log in user
$data = array(
'name' => $user->name,
'email' => $user->email,
'id' => $user->id,
'loggedin' => TRUE,
);
$this->session->set_userdata($data);
}
}
public function logout()
{
$this->session->sess_destroy();
}
public function loggedin()
{
return (bool) $this->session->userdata('loggedin');
}
public function hash ($string)
{
return hash('sha512', $string . config_item('encryption_key'));
}
}
당신은 구문 오류가 있습니다. 편집 해 주시겠습니까? – Yellow
짧은 시일 내에 로그인 상태를 다른 상태로 유지하고 시도하십시오. – Rorschach
여전히 같은 오류가 발생합니다. : – Yellow