$config['sess_use_database']
为TRUE
时,我在使用Flash消息时遇到问题。无论何时,FALSE
它都可以正常运行。下面是我的代码和我的配置文件。当我尝试将会话存储在数据库中时,为什么它不起作用?
配置文件
$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'] = TRUE;
$config['sess_time_to_update'] = 300;
控制器
$this->session->set_flashdata('item', array('message' => 'Record created successfully','class' => 'success'));
redirect('dashboard');
信息中心视图
if(!empty($this->session->flashdata('item'))) {
$message = $this->session->flashdata('item');
echo "<div class='" . $message['class'] . ">" . $message['message'] . "</div>";
}