浏览器重启后,CodeIgniter会删除会话

时间:2012-10-01 09:26:42

标签: codeigniter

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

1 个答案:

答案 0 :(得分:0)

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

在application / config / config.php中:

$config['sess_expire_on_close'] = FALSE;