I have a standard situation where I am using PHP sessions and I want to log a user out. The logout function is essentially as follows:
Code: Select all
function logout() {
@ $olduser = $_SESSION['userid'];
$_SESSION = array();
$result_destroy = session_destroy();
if (!empty($olduser)) {
if ($result_destroy) {
$data['logout_msg'] = 'You have been logged out successfully.';
} else {
$data['logout_msg'] = 'Could not log you out.';
}
} else {
$data['logout_msg'] = 'You were not logged in, and so have not been logged out.';
}
}How can this be possible if session variables only exist on server side and they've been destroyed?!
Very confused,
Andy