Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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']);
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top