When I click Logout, I'm unable to unset the value of the session variable. Please find my code below. I'm not sure where I'm going wrong
View:
<? if (!isset($this->session->userdata['user_full_name'])): ?>
<li class=""><a href="#" onclick="Login()">Login with FB</a></li>
<? endif; ?>
<? if (isset($this->session->userdata['user_full_name'])): ?>
<li class=""><a href="#"><? echo $this->session->userdata['user_full_name']; ?></a></li>
<li class=""><a href="" onclick="Logout()">Logout</a></li>
<? endif; ?>
JS
function Logout()
{
FB.logout(function(response) {
confirm("You have successfully logged out from FB");
window.location.href = 'http://localhost:8080/auth/logout';
//window.location.reload();
console.log(response);
});
}
Controller
function logout()
{
$this->session->set_userdata(array(
'user_email' => '',
'user_full_name' => '',
'user_gender' => ''
));
$this->session->sess_destroy();
redirect('default_controller');
}