[eluser]sketchynix[/eluser]
Make sure the URL helper is loaded
Don't use
) when checking the session data. The reason is isset checks to see if the variable exists and that it is not NULL.
Code:
$this->session->userdata()
will either return FALSE or the value of the session data, so the isset will evaluate to true every time.
Let me know if that doesn't work.
Code:
class Entrar extends Controller {
function __construct() {
parent::Controller();
$this->load->model('conta_model');
$this->load->helper('url');
}
function index()
{
$data['conteudo'] = 'site/entrar';
$this->load->view('includes/conteudo', $data);
$this->conectado(); // THIS VERIFY IF USER IS LOGGED, THEN, IF YES, REDIRECT TO DASHBOARD
}
function conectado(){
$conectado = $this->session->userdata('conectado');
if($conectado != false) {
redirect('/dashboard');
}else{
die();
}
}
function desconectar() {
$this->session->sess_destroy();
redirect('/entrar', 'refresh');
die();
}
}