I want to log the user out without reloading the page, just updating some divs. This is what I have but obviously not working. The session unsets only after reloading the page.
$.ajax({
url: "logout.php",
method: "post",
data: "account_type=twitter",
success: function () {
/*****do something***********/
}
});
in logout.php
<?php
session_start();
if(isset($_POST['account_type']) && $_POST['account_type'] == "twitter") {
unset($_SESSION['twitterId']);
unset($_SESSION['twitterName']);
unset($_SESSION['twitterPic']);
unset($_SESSION['twitterUrl']);
unset($_SESSION['access_token']);
unset($_SESSION['token_oauth']);
header("Location: index.php");
}
?>
some help would be greatly appreciated. Thanks!