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
)