我有这个控制器,它使用 facebook 凭据登录用户。
public function Facebook() {
$fb_data = $this->session->userdata('fb_data');
// This array contains all the user FB information
$data['fb_data'] = $fb_data;
$fb = $data['fb_data']['me']['id'];
$userdata = $this->user_model->getID($fb);
$userID = $userdata['0']['id'];
$userNick = $userdata['0']['nick'];
$session_array = array(
'id' => $userID,
'userNick' => $userNick
);
$this->session->set_userdata('user_data',$session_array);
$user = $this->session->userdata('user_data');
print_r($this->session->all_userdata());
//print_r($user);
if($user['id'] && $user['userNick']) {
redirect('/');
}
}
它运行良好,但在浏览器重新启动后会话被删除。没有创建任何 cookie。
会话配置:
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 0;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = FALSE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;