0

When user presses the logout button, it doesn't clear the session or cookies. That means after I refresh it, it's still logged in. After I added destroy session it works, but it also logs out my facebook on www.facebook.com together with my web site.

<?php
function facebooklogin(){
    include ('libs/facebook.php');

$facebook = new Facebook(array(
    'appId' => '[my app id]',
    'secret' => '[my secret]',
    'cookie' => true
));

$session = $facebook->getUser();
$me = null;

if ($session)
{
    try
    {
        $me = $facebook ->api('/me');
                $facebook->api ('/me');
                $_SESSION['id'] = $me['id'];
                $_SESSION['email'] = $me['email'];
                $_SESSION['name'] = $me['name'];
        //print_r($me);
                printf($me['id']);
                printf($me['email']);
                printf($me['name']);
    }
    catch (FacebookApiException $e)
    {
        echo $e->getMessage();
    }
}

if ($me)
{
        $logoutUrl = $facebook->getLogoutUrl();
    echo "<a href='$logoutUrl'><img src=assests/images/fblogoutbtn.png></a>";
}
else
{
    $loginUrl = $facebook->getLoginUrl(array(
                'scope' => 'publish_stream, read_friendlists,email')
                );
    echo "<a href='$loginUrl'><img src=assests/images/fbbtn.png></a>";
}

}
4

0 回答 0