Reputation: 3928
I need to get an anchor tag to delete a session in php + log the user out of Facebook. Before I used Facebook connect, I was using this php code to destroy the session:
if(isset($_GET['logoff'])){
$_SESSION = array();
session_destroy();
header("Location: /");
exit;
}
And this for the anchor tag:
<a href='?logoff'>Log Out</a>
I now need the same anchor tag to go to the $logoutUrl + destroy the session.
Upvotes: 1
Views: 6607
Reputation: 682
This worked for my app
if(isset($_GET['logout'])=='1'){
if (isset($_SESSION['fb_' . $app_id . '_code'])) {
unset ($_SESSION['fb_' . $app_id . '_code']);
}
if (isset($_SESSION['fb_' . $app_id . '_access_token'])) {
unset ($_SESSION['fb_' . $app_id . '_access_token']);
}
if (isset($_SESSION['fb_' . $app_id . '_user_id'])) {
unset ($_SESSION['fb_' . $app_id . '_user_id']);
}
}
Upvotes: 1
Reputation: 4211
I could be wrong but I am pretty sure Facebook saves the access token in a cookie called fbs_YOURAPPID. So just destroy that cookie and you should sign-out.
Upvotes: 3