使用CodeIgniter 1.7开发我的Web应用程序时,仅使用Chrome浏览器打开时出现错误 ERR_RESPONSE_HEADERS_TOO_BIG 。我尝试了所有其他浏览器,不会发生错误。
刷新错误页面后,我可以正常打开页面。我尝试从谷歌搜索,从2009年到现在,Chrome用户似乎发生了这个错误。
这是我的控制器代码:
function search_daily_sales_summary_view()
{
if(!($this->session->userdata('DAILY_SALES_SUMMARY'))){
$this->session->set_flashdata('error', 'You dont have the permission to access that page.');
redirect('login/home');
}
$this->load->model('currency_model');
$this->load->model('bill_model');
$data = array();
$report = array();
if($query = $this->currency_model->list_currency())
{
foreach ($query as $row) {
$currencyid = $row->CURRENCY_ID;
$currencycode = $row->CURRENCY_CODE;
if($buyData = $this->bill_model->calculate_buy($currencyid))
{
$totalbuy = $buyData->total_from_amount;
$totalbuy_rate = $buyData->rate;
if($buyData->total_from_amount=='')
{
$totalbuy = 0.00;
}
if($buyData->rate=='')
{
$totalbuy_rate = 0.00;
}
}
else
{
$totalbuy = 0.00;
$totalbuy_rate = 0.00;
}
if($sellData = $this->bill_model->calculate_sell($currencyid))
{
$totalsell = $sellData->total_from_amount;
$totalsell_rate = $sellData->rate;
if($sellData->total_from_amount=='')
{
$totalsell = 0.00;
}
if($sellData->rate=='')
{
$totalsell_rate = 0.00;
}
}
else
{
$totalsell = 0.00;
$totalsell_rate = 0.00;
}
$report[] = array("currency"=>$currencycode, "buy"=>$totalbuy, "buyrate"=>$totalbuy_rate, "sell"=>$totalsell, "sellrate"=>$totalsell_rate);
}
$data['records'] = $report;
}
$this->load->model('company_model');
if($query = $this->company_model->list_company())
{
$data['company_list'] = $query;
}
$this->load->model('branch_model');
if($this->input->post('company'))
{
$companyid = $this->input->post('company');
if($query = $this->branch_model->view_company_branch($companyid))
{
$data['branch_list'] = $query;
}
}
else
{
if($query = $this->branch_model->list_branch())
{
$data['branch_list'] = $query;
}
}
$this->load->view('report/daily_sales_summary', $data);
}
如何解决这个问题?
答案 0 :(得分:2)
CI将会话存储在cookie中。如果你在cookie中存储太多,就会出错。
将CodeIgniter设置为使用数据库会话,或将其保存到文件中。
答案 1 :(得分:1)
Saving Session Data to a Database
CREATE TABLE IF NOT EXISTS `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(16) 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`)
);
Note: By default the table is called ci_sessions, but you can name it anything you want as long as you update the application/config/config.php file so that it contains the name you have chosen. Once you have created your database table you can enable the database option in your config.php file as follows:
$config['sess_use_database'] = TRUE;
Once enabled, the Session class will store session data in the DB.
Make sure you've specified the table name in your config file as well:
$config['sess_table_name'] = 'ci_sessions';
Note: The Session class has built-in garbage collection which clears out expired sessions so you do not need to write your own routine to do it.