0

我有这个控制器,它使用 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;
4

1 回答 1

0

http://codeigniter.com/user_guide/libraries/sessions.html

在应用程序/config/config.php 中:

$config['sess_expire_on_close'] = FALSE;
于 2012-10-01T09:33:30.853 回答