![]() |
$this->session->sess_destroy(); doesn't destroy all session - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: $this->session->sess_destroy(); doesn't destroy all session (/showthread.php?tid=43862) |
$this->session->sess_destroy(); doesn't destroy all session - El Forum - 07-26-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 based on this http://ellislab.com/codeigniter/user-guide/libraries/sessions.html it should destroy all $this->session->sess_destroy(); doesn't destroy all session - El Forum - 07-26-2011 [eluser]WanWizard[/eluser] Sigh. As I said (and this is the third time), sess_destroy() doesn't erase the user_data array. I know it says that. But it doesn't. And it never did. $this->session->sess_destroy(); doesn't destroy all session - El Forum - 07-26-2011 [eluser]Alpha[/eluser] ![]() tnx a lot ![]() $this->session->sess_destroy(); doesn't destroy all session - El Forum - 07-05-2012 [eluser]tinawina[/eluser] Ok - I did read the manual, and I started out using $this->session->sess_destroy() and that didn't work so I came here and found this post. Tried unset($this->session->userdata) but that didn't kill my session either. What I ended up doing is killing each session variable individually: $this->session->unset_userdata('username'); $this->session->unset_userdata('userid'); $this->session->unset_userdata('useremail'); ... To do this quickly you could loop through the session array, turning each one off as you loop. This was the only way I found to kill my session. $this->session->sess_destroy(); doesn't destroy all session - El Forum - 07-05-2012 [eluser]WanWizard[/eluser] sess_destroy() does destroy the session, but it doesn't reset already loaded data. Ideally, after you destroy the session, you should do a redirect and not continue. $this->session->sess_destroy(); doesn't destroy all session - El Forum - 07-05-2012 [eluser]tinawina[/eluser] Right - I do a redirect with a refresh and all works fine. I'll try sess_destroy(). Thanks. $this->session->sess_destroy(); doesn't destroy all session - El Forum - 07-05-2012 [eluser]InsiteFX[/eluser] Code: $this->session->userdata = array(); $this->session->sess_destroy(); doesn't destroy all session - El Forum - 07-05-2012 [eluser]tinawina[/eluser] InsiteFX - like! $this->session->sess_destroy(); doesn't destroy all session - El Forum - 07-05-2012 [eluser]skunkbad[/eluser] If you really want to delete the entire session, and not leave anything behind, you can use php's setcookie() function. Code: <?php This would delete the entire session cookie. Remember, you are not limited to CodeIgniter when using CodeIgniter, it's just a framework. Actually, if you already use the cookie helper, you can just use: Code: delete_cookie( config_item('sess_cookie_name') ); |