1
I have a small login problem with codeigniter, after logging in it does not transfer the data by session.
I took the following test:
- I printed the session in the controler [ok, printed correct data]
- I printed the session on another controller [printed nothing]
- cleared Cache
public function login(){ $usuario = $this->input->post('usuario'); // recebe name usuario pelo post $senha = $this->input->post('senha'); $this->db->where('usuario', $usuario); // pega o valor igual ao usuario do post no banco $this->db->where('senha', $senha); $this->db->where('ativo',1); $usuario = $this->db->get('usuarios')->result(); if (count($usuario)===1) { $dados = array( 'usuario'=>$usuario[0]->usuario, 'logado'=> TRUE ); $this->session->set_userdata($dados); //print_r($dados); redirect('administracao/categorias'); }else{ echo heading('Usuario não encontrado', 2); } }
Login Verification:
class Categorias extends CI_Controller{ public function __construct(){ parent::__construct(); if (!$this->session->userdata('usuario') || !$this->session->userdata('logado')) { redirect('administracao/home'); } }
Could put the source code?
– rray
@rray Update with the code
– Yanick Gomes