miércoles, 26 de junio de 2013

Logout in codeigniter

I had a problem with my function logout in codeigniter. I'm following a course at tutsplus called "CodeIgniter Essentials" but the function that they show didn't work for me. I got a "Page not found" error.

After searching for a while I found the answer in this page: Logout codeigniter .

My original code was:

$this->session->sess_destroy();
redirect(base_url().'posts');


Now the code that works is:

$this->session->unset_userdata('userID');
$this->session->unset_userdata('user_type');
$this->session->sess_destroy();
redirect(base_url().'posts');


The explanation is in the link provided.

This are my first steps with this framework and I really like it.

That's all!!