codeigniter 注销Facebook连接会话

kpbpu008  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(97)

我正试图将我的网站与facebook连接处理facebook注册和facebook登录。我用的是codeigniter框架。但我现在有个问题
1.当前Facebook登录用户为“test1”。我去我的网站注册facebook,一切正常,“test1”的信息存储在我的数据库中。然而,在我从facebook上注销test1,并在facebook上登录“test 2”后,我回到我的网站,再次在facebook上注册,它仍然存储着“test1”的信息。
1.我使用离子认证库来处理用户从我的网站注销。但是,在我切换Facebook测试用户帐户并再次做了一次“用Facebook登录”后,它仍然获得了之前的Facebook用户。
根据上面的2个案例,似乎Facebook会话没有被清除?我在这个问题上挣扎了很长时间,请帮帮忙!
我使用这个来获取用户数据:$fb_usr = $this->fb_connect->user;(似乎不管Facebook用户如何更改,fb_connect总是返回相同的用户)
fb_connect是这样的:

<?php
        include(APPPATH.'libraries/facebook/facebook.php');

        class Fb_connect extends Facebook{

            //declare public variables
            public  $user           = NULL;
            public  $user_id        = FALSE;

            public $fbLoginURL  = "";
            public $fbLogoutURL = "";

            public $fb          = FALSE;
            public $fbSession   = FALSE;
            public $appkey      = 0;

            //constructor method.
            public function __construct() 
            {
                        $CI = & get_instance();
                        $CI->config->load("facebook",TRUE);
                        $config = $CI->config->item('facebook');
                        parent::__construct($config);
                        $this->user_id = $this->getUser(); // New code
                        $me = null;
                        if ($this->user_id) {
                            try {
                                $me = $this->api('/me');
                                $this->user = $me;
                                } catch (FacebookApiException $e) {
                                    error_log($e);
                                }
                }   

                if ($me) {
                    $this->fbLogoutURL = $this->getLogoutUrl();
                } else {
                    $this->fbLoginURL = $this->getLoginUrl();
                }           
            } //end Fb_connect() function
}
gg0vcinb

gg0vcinb1#

我认为您需要做的是为getLogoutUrl()调用设置“next”参数。就像这样:

$args['next'] = site_url('logout'); // replace "logout" with your controller which will clear the session
$fbLogoutURL = $facebook->getLogoutUrl($args);

然后,在控制器中设置为“next”,您需要清除会话数据。

class Logout extends CI_Controller {
    public function index() {
        $facebook->destroySession();       
        $this->session->sess_destroy();  // Assuming you have session helper loaded
        $this->load->view('logout');
    }
}

如果有帮助就告诉我。

相关问题