Código PHP:
public function login_submit()
{
$this->loggedIn();
$this->_rulesFrom();
if(!$this->form_validation->run())
{
$mensaje = validation_errors();
echo json_mensaje(0,$mensaje);
}
else
{
$hasher = new PasswordHash(PHPASS_HASH_STRENGTH, PHPASS_HASH_PORTABLE);
$data = array(
'identi' => $this->input->post('identi'),
'password' => $this->input->post('password'),
);
$user = $this->usuario_model->existeIdenti($data['identi']);
if($user != NULL)
{
if($hasher->CheckPassword($data['password'], $user->user_password))
{
// $this->session->regenerateSessionId();
//Destruimos la session
$this->session->sess_destroy();
//Creamos una nueva session
$this->session->sess_create();
$this->usuario_model->updateLogin($user->user_id, $this->session->userdata('session_id'));
if($user->user_rango == 1)
{
$session = array('is_admin' => 1);
$this->session->set_userdata($session);
}
unset($user->user_password);
$session = array(
'user_name' => $user->user_name,
'user_email' => $user->user_email,
'user_id' => $user->user_id,
'user_avatar' => $user->user_avatar,
'user_online' => TRUE,
);
$this->session->set_userdata($session);
echo json_mensaje(1, "");
}
else
{
echo json_mensaje(0, 'Datos incorrectos');
}
}
else
{
echo json_mensaje(0, 'Usuario o Email incorrecto');
}
}
}