php - Facebook SDK logout not working -
i'm using facebook php-sdk sign in users , works fine. i'm having problem logging users out correctly. after clicking logout button , clicking sign in button not redirect user facebook's sign in page, instead logs them site if logout wasn't successful. here code sign in user:
function authenticate_user() { $ci = & get_instance(); $ci->config->load("facebook",true); $config = $ci->config->item('facebook'); $ci->load->library('facebook', $config); $user = $ci->facebook->getuser(); if ($user) { try { $user_profile = $ci->facebook->api('/me'); return $user_profile; } catch (facebookapiexception $e) { error_log($e); } } return false; } public function signin() { $user_profile = authenticate_user(); if (!$user_profile) { $loginurl = $this->facebook->getloginurl(array('scope' => 'email')); redirect($loginurl); } $this->load->model("user_model"); if ($userrow = $this->user_model->user_exists($user_profile["id"])) { set_session($user_profile, $userrow->privileges); redirect("member_controller/members"); } }
this logout code:
public function fb_signout() { $params = array( 'next' => 'http://www.' + $host + '/index.php/authentication_controller/signout'); redirect($this->facebook->getlogouturl($params)); // $params optional. } public function signout() { $this->session->sess_destroy(); redirect("http://www." + $host + "/"); }
update:
the sdk using native php sessions , calling $this->session->sess_destroy()
not destroy it, needed include session_destroy()
in signout function.
the facebook sdk uses native php sessions codeigniter doesn't. want add session_destroy();
in signout controller kill php native session.
hope helps!
Comments
Post a Comment