Excellent night, I hope you can help me, when I send my function call to destroy the session, it is not destroyed and it is still active if I try to enter the URL.
my controller is the following, to start and of course here is the function to be able to destroy the session
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class login extends CI_Controller {
public function __constuct(){
parent::__construct();
}
public function index(){
if($this->session->userdata('username')){
redirect('admin');
}
if(isset($_POST['password'])){
$this->load->model('usuario_model');
if($this->usuario_model->login($_POST['username'],md5($_POST['password']))){
$this->session->set_userdata('username',$_POST['username']);
redirect('admin');
}else{
redirect('login');
}
}
$this->load->view('login');
}
public function logout(){
$this->session->sess_destroy();
redirect('login');
}
}
I send the function from my view as follows:
<header>
<nav>
<a href="<?=site_url('login/logout') ?>">Salir</a>
</nav>
</header>