System logs alone in any action

2

Gentlemen, In my administrative system I log in normal ... However, any action inside the system, it logs alone ... Without clicking on logout nothing ... Would anyone know to describe to me if you already had this type of problem? Of course I'm putting the Controller here.

Controller

public function verificarLogin(){

    $this->load->library('form_validation');
    $this->form_validation->set_rules('email','Email','valid_email|required|xss_clean|trim');
    $this->form_validation->set_rules('senha','Senha','required|xss_clean|trim');
    $ajax = $this->input->get('ajax');
    if ($this->form_validation->run() == false) {

        if($ajax == true){
            $json = array('result' => false);
            echo json_encode($json);
        }
        else{
            $this->session->set_flashdata('error','Os dados de acesso estão incorretos.');
            redirect($this->login);
        }
    } 
    else {

        $email = $this->input->post('email');
        $senha = $this->input->post('senha');

        $this->load->library('encrypt');   
        $senha = $this->encrypt->sha1($senha);

        $this->db->where('email',$email);
        $this->db->where('senha',$senha);
        $this->db->where('situacao',1);
        $this->db->limit(1);
        $usuario = $this->db->get('usuarios')->row();
        if(count($usuario) > 0){
            $dados = array('nome' => $usuario->nome, 'id' => $usuario->idUsuarios,'permissao' => $usuario->permissoes_id , 'logado' => TRUE);
            $this->session->set_userdata($dados);

            if($ajax == true){
                $json = array('result' => true);
                echo json_encode($json);
            }
            else{
                redirect(base_url().'administrar');
            }


        }
        else{


            if($ajax == true){
                $json = array('result' => false);
                echo json_encode($json);
            }
            else{
                $this->session->set_flashdata('error','Os dados de acesso estão incorretos.');
                redirect($this->login);
            }
        }

    }

}

Note

Inside the system I have a controller and a model that manages to Add / Edit / Remove within the users table ... maybe it has something to do with this logout ... If anyone can help me, I'm grateful.

Request for Login

    if((!$this->session->userdata('session_id')) || (!$this->session->userdata('logado'))){
        redirect('administrar/login');
    }

print_r () result

[userdata] => Array
    (
        [session_id] => 11bd5976ec8ec9d15de1f29277bb4e61
        [ip_address] => 201.10.93.25
        [user_agent] => Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36
        [last_activity] => 1436637190
        [user_data] => 
        [nome] => Administrador
        [id] => 1
        [permissao] => 1
        [logado] => 1
    )
    
asked by anonymous 11.07.2015 / 19:40

1 answer

0

I already had this problem with codeigniter (and you will always have problems with it) when I set the session to be saved as cookie .

Change the option from cookie to database . I think the problem is cookie only contain a certain amount of data.

    
20.08.2015 / 18:47