2016-03-09 87 views
0

我有保存會話介紹數據庫的問題Codeigniter不希望將會話寫入數據庫。codeigniter 2.2.6會話到數據庫

我autoload.php

$autoload['libraries'] = array('session','database'); 

我的config.php

$config['sess_cookie_name']  = 'ci_session'; 
$config['sess_expiration']  = 7200; 
$config['sess_expire_on_close'] = TRUE; 
$config['sess_encrypt_cookie'] = TRUE; 
$config['sess_use_database'] = TRUE; 
$config['sess_table_name']  = 'ci_sessions'; 
$config['sess_match_ip']  = TRUE; 
$config['sess_match_useragent'] = TRUE; 
$config['sess_time_to_update'] = 300; 

我的表

CREATE TABLE IF NOT EXISTS `ci_sessions` (
    session_id varchar(40) DEFAULT '0' NOT NULL, 
    ip_address varchar(45) DEFAULT '0' NOT NULL, 
    user_agent varchar(120) NOT NULL, 
    last_activity int(10) unsigned DEFAULT 0 NOT NULL, 
    user_data text NOT NULL, 
    PRIMARY KEY (session_id), 
    KEY `last_activity_idx` (`last_activity`) 
); 

誰能幫助我?

+0

使用任何前綴?? – devpro

+0

編號$ config ['cookie_prefix'] \t =「」; $ config ['cookie_domain'] \t =「」; $ config ['cookie_path'] \t \t =「/」; $ config ['cookie_secure'] \t = FALSE;我使用Ubuntu 14 – Vlada

+0

只是'FALSE'的'$配置[ 'sess_match_useragent']' – devpro

回答

1

只是False$config['sess_match_useragent']

$config['sess_cookie_name']  = 'ci_session'; 
$config['sess_expiration']  = 7200; 
$config['sess_expire_on_close'] = FALSE; 
$config['sess_encrypt_cookie'] = FALSE; 
$config['sess_use_database'] = TRUE; 
$config['sess_table_name']  = 'ci_sessions'; 
$config['sess_match_ip']  = FALSE; 
$config['sess_match_useragent'] = FALSE; 
$config['sess_time_to_update'] = 300; 

從用戶指南:

sess_match_useragent用來是否讀會話數據時,用戶代理相匹配。

CI Session User Guide

+0

它沒有幫助,我改變了。 – Vlada

+0

你還需要假'sess_expire_on_close,sess_encrypt_cookie,sess_match_ip' @Vlada – devpro

+0

再次沒有什麼,我的數據庫仍然是空的 – Vlada