注销facebook连接会话 [英] logout facebook connect session

查看:254
本文介绍了注销facebook连接会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图整合我的网站与Facebook的连接,以处理Facebook注册和Facebook登录。我使用codeigniter框架。但我现在遇到这个问题:

I'm trying to integrate my site with facebook connection to handle facebook signup and facebook login. i'm using codeigniter framework. But I got this problem now:


  1. 当前Facebook登录用户是test1。我去我的网站注册与Facebook,一切工作正常,test1的信息存储在我的数据库。但是,我从Facebook登录test1,并在Facebook上登录test2,我回到我的网站,并再次与Facebook注册,它仍然test1的信息存储。

  1. current facebook login user is "test1". I go to my site to sign up with facebook, everything works fine and "test1"'s info are stored in my database. However, after I log test1 out from facebook, and login "test2" in on facebook, I go back to my site and do a signup with facebook again, it still "test1"'s info stored.

我使用离子授权库处理用户从我的网站注销。但是,我切换Facebook测试用户帐户,并做一个登录与Facebook,再次,它仍然获得以前的Facebook用户。

I use ion auth library to handle user logout from my site. However, after I switch facebook test user accounts and do a "login with facebook" again, it still get the previous facebook user.

根据上述2个案例,Facebook会话似乎没有清除?

Based on the 2 cases above, it seems that the facebook session wasn't cleared up? I'm struggling on this problem for a long time, please help!

我用这个来获取用户数据:
$ fb_usr = $ this-> fb_connect - >用户;
(似乎无论Facebook用户如何改变,fb_connect总是返回相同的用户)

I user this to get user data: $fb_usr = $this->fb_connect->user; (it seems that no matter how the facebook user changs, fb_connect always return same user)

和fb_connect是sth这样:

and fb_connect is sth like this:

    <?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
}


推荐答案

我想你需要做的是为您的getLogoutUrl()调用设置下一个参数。像这样:

I think what you need to do is set the "next" param for your getLogoutUrl() call. Something like this:

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

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

Then, in the controller set as "next" you'll need to clear the session data.

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

让我知道如果有帮助。

这篇关于注销facebook连接会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆