Codeigniter与facebook php sdk 3.2.3注销无法正常工作

时间:2013-12-27 07:17:56

标签: facebook codeigniter

Facebook退出无效

我希望当用户点击退出时,用户将从应用以及Facebook注销。

<?php if($ this-> session-> userdata('user_id')):

$CI = & get_instance();
$CI->config->load("facebook",TRUE);
$config = $CI->config->item('facebook');
$this->load->library('Facebook', $config);
$myurl = site_url('user/mainLogout'); 
$token= $this->facebook->getAccessToken();
$params = array('next' => $myurl,'access_token'=>$token);
$logoutUrl=$this->facebook->getLogoutUrl($params);

>

< li style =“float:right”>< a href =“<?php echo $ logoutUrl; // site_url('logout');?>”> Logout< / a> < /锂> <?php endif; ?>

在mainLogout()

function mainLogout(){

    $SessionArray = array(
        'user_id' => '',
        'user_email' => '',
        'role' => ''
    );
    $this->session->unset_userdata($SessionArray);
    $this->session->sess_destroy();
    $this->facebook->destroySession();
    setcookie('PHPSESSID', '', time()-3600, "/");
    setcookie ("fbss_XXXXXXXXXX", "", time() - 3600);
    unset($_SESSION);
    session_destroy();
    redirect(site_url(''));

}

1 个答案:

答案 0 :(得分:0)

You have to destroy the session

using the following commands.

unset($_SESSION);
// Delete all session variables
session_destroy();