[eluser]Unknown[/eluser]
Hi
I am building a logout function, but every time the user is logging out the data is recreated for some reason. Even though i have tried everything to kill the data.
The following methods is what I have tried:
- [ session->unset_userdata('user_id'); ]
- [ session->sess_destroy(); ]
- Delete the entry in the database.
- Deleted the cookie which hold user information.
- Destroyed all cookie and session information.
Right now my code look like this:
Code:
public function logout()
{
// Load needed classes
$ci =& get_instance();
$ci->session->unset_userdata('user_id');
$user_id = $ci->session->userdata('user_id');
if(!empty($user_id))
{
return false;
}
$ci->login_model->del_user_session($ci->session->userdata('session_id'));
delete_cookie('checkout_session');
setcookie('checkout_session', '', time()-42000, '/');
return true;
}