$this->session->sess_destroy(); doesn't destroy all session |
[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-gui...sions.html it should destroy all
[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.
[eluser]Alpha[/eluser]
i want to report this as a bug, my session database has been spammed with session_id due to my troubleshooting of login-logout. ok that's the last. tnx a lot
[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.
[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.
[eluser]tinawina[/eluser]
Right - I do a redirect with a refresh and all works fine. I'll try sess_destroy(). Thanks.
[eluser]InsiteFX[/eluser]
Code: $this->session->userdata = array();
[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') ); |
Welcome Guest, Not a member yet? Register Sign In |