php - 重定向后 Codeigniter session 销毁

标签 php codeigniter session

enter image description here

我正在 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/

相关文章:

php - SQL 查询失败

php - 在哪里为 Angular-Codeigniter 项目中的图形创建数组

php - 为什么此 PHP 脚本(由 AJAX 调用)随机无法正确加载 SESSION?

java - Google App Engine Java - 在用户关闭浏览器后保持 session Activity (记住我功能)

java - JSP在 session 中存储密码

php - 如何在mysql中使用php对表的任何单独行进行只读?

php - 需要 paypal 的简单 php SoapClient 示例

mysql - codeigniter - 数据库 : how to update multiple tables with a single update query

php - 如何检查 id 是否已经存在 - codeigniter

php - 如何在 PHP 中将数字格式化为美元金额