I'm trying to send the data from the bank to the session, gave a print_r in the data received from the bank, but I can not pass it to the session, follow the code.
Controller
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class login extends CI_Controller {
public function entrar(){
$mensagem = null;
if($this->input->post('acessar') === 'acessar'){
$this->form_validation->set_rules('user', 'email', 'required|valid_email');
$this->form_validation->set_rules('senha', 'senha', 'required|min_length[5]|max_length[40]');
if($this->form_validation->run() === true){
$this->load->model('LoginModel');
$email = $this->input->post('user');
$senha = md5($this->input->post('senha'));
$loginExistente = $this->LoginModel->verificaLogin($email,$senha);
if($loginExistente === true){
$usuario = $loginExistente;
redirect('administracao/index');
}else{
$mensagem = array('class' => 'danger',
'mensagem' => 'Login inválido, e-mail ou senha incorretos.'
);
}
}else{
$mensagem = array('class' => 'danger',
'mensagem' => 'Foram encontrados erros no login </br>'. validation_errors()
);
}
}
$dados = array('alerta' => $mensagem);
$this->load->view('login/index', $dados);
}
public function sair(){
$this->session->sess_destroy();
redirect('login/entrar');
}
}
Here's the model
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class LoginModel extends CI_Model {
public function verificaLogin($email,$senha){
$this->db->where('email', $email);
$this->db->where('senha', $senha);
$usuario = $this->db->get('useradmin')->row();
$total = count($usuario);
print_r($usuario); die();
if($total == 1){
$data = array(
'id' => $usuario->id,
'nome' => $usuario->nome,
'email' => $usuario->email,
'nivel' => $usuario->nivel,
'logado' => true
);
$this->session->set_userdata($data);
/*$user = $usuario->result_array();*/
/*return $user[0];*/
return true;
}else{
return false;
}
}
}
And that's when I give a print_r and try to log in
stdClass Object ( [id] => 1 [nome] => Débora [email] => [email protected] [senha] => 698dc19d489c4e4db73e28a713eab07b [nivel] => 1 )
Could you help me handle this, please?