我正在尝试使用 Facebook 登录我的网站,它适用于除 IE9 之外的所有浏览器!
我的函数一直到 'redirect('home');' 但随后停止并停留在当前页面上。所以所有的会话数据都设置好了,用户登录到 Facebook,但他们留在登录页面上而没有被重定向。
这是我的代码:
public function fb_login()
{
if($this->fb_connect->user_id){
$this->session->unset_userdata('logged');
$this->session->unset_userdata('user_data');
// Check if the user had previously logged in using facebook connect
$fb_user = $this->fb_connect->user;
$user_details = $this->Model->check_fb_user($fb_user);
// This will then return their user details
if($user_details['status'] == 0) redirect('account');
$user_data['raw_details'] = $user_details;
$user_data['fb_id'] = $this->fb_connect->user_id;
$user_data['join_date'] = date( 'dS F, Y', strtotime($user_details['date_added']) );
$user_data['location'] = $user_details['user_location'];
$user_data['name'] = $user_details['user_fname'] . ' ' . $user_details['user_lname'];
$user_data['display_name'] = $user_details['user_display_name'];
$user_data['fb_dp'] = 'https://graph.facebook.com/'.$user_details['fb_id'].'/picture';
$this->session->set_userdata('user_data',$user_data);
if($this->session->userdata('referer')){
$referer = $this->session->userdata('referer');
$this->session->unset_userdata('referer');
redirect($referer);
}else{
redirect('home');
}
}else{
error_log('148');
redirect('account/login');
}
}