我正在 session 中添加订单 ID 和购物车项目。如果我在 session 中添加 2 个购物车项目。它工作正常。如果我在 session 中添加 3 个或更多购物车项目。重定向后的所有数据都丢失了。 Controller 的名称是 checkout。
function pay_order($order_id){
$this->load->helper('url');
$this->load->library('session');
$this->load->library('cart');
$this->load->helper('url');
$this->load->helper('form');
$output = $this->cart->contents();
$output = $this->sort_array($output);
$list['data'] = $output;
$list['order_id'] = $order_id;
$this->session->set_userdata('ses', $list);
echo '<pre> Session Before Redirect';
print_r($this->session->userdata('ses'));// all data present.
redirect('checkout/do_payment');
}
function do_payment(){
$this->load->helper('url');
$this->load->helper('url');
$this->load->library('session');
$this->load->library('cart');
$this->load->helper('url');
$this->load->helper('form');
$this->load->library('session');
$this->load->model('customer_model');
echo 'After redirect<pre>';
print_r($this->session->userdata('ses'));// does not get any data here.
}
还附加了重定向前的快照。
最佳答案
你的配置是什么 应用程序/配置/config.php
如果是 $config['sess_use_database'] = FALSE;
这意味着您将 session 信息存储在 cookie 中,限制为 4kb。 可能这就是问题所在。在数据库中存储大量数据。
http://ellislab.com/codeigniter/user-guide/libraries/sessions.html
关于php - 重定向后 Codeigniter session 销毁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19105321/