0
Good Day Fellows.Codeigniter Login session Неизвестная ошибка
У меня проблема с регистрацией в 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