CodeIgniter Forums
$this->session->sess_destroy(); didn't destroy all session? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: $this->session->sess_destroy(); didn't destroy all session? (/thread-43849.html)



$this->session->sess_destroy(); didn't destroy all session? - El Forum - 07-25-2011

[eluser]Alpha[/eluser]
hi, i have $this->session->set_userdata('user_id', 'ID1');

then i want to logout and used $this->session->sess_destroy();
but to my surprise $this->session->set_userdata('user_id', 'ID1') still exist, see below how i used $this->session->sess_destroy();

$this->load->view('index', $data);
$this->session->sess_destroy();

tnx


$this->session->sess_destroy(); didn't destroy all session? - El Forum - 07-25-2011

[eluser]WanWizard[/eluser]
It destroys the session, but doesn't empty the userdata array already loaded.


$this->session->sess_destroy(); didn't destroy all session? - El Forum - 07-25-2011

[eluser]Alpha[/eluser]
i get it, user_data uses session database and ci session is not like php native session wherein once u run session destroy all data stored in session object will be destroyed

tnx Smile


$this->session->sess_destroy(); didn't destroy all session? - El Forum - 07-25-2011

[eluser]Alpha[/eluser]
based on http://ellislab.com/codeigniter/user-guide/libraries/sessions.html session destroy should destroy all items but why user_data still exist?


$this->session->sess_destroy(); didn't destroy all session? - El Forum - 07-26-2011

[eluser]WanWizard[/eluser]
As I said, sess_destroy() doesn't empty the user_data array.

It's a 'bug/feature' that's been there since the beginning of time. If this is a problem for you, either report it to have it fixed, or extend the session class and erase it yourself.