Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
重定向会话在codeigniter中丢失后_Codeigniter - Fatal编程技术网

重定向会话在codeigniter中丢失后

重定向会话在codeigniter中丢失后,codeigniter,Codeigniter,重定向后会话值丢失。我正在从pay_order方法重定向到do_支付方法。当我在do_payment method中打印会话值时,其返回值为false。只需简单调用do_payment方法即可显示会话值。请帮助重定向有什么问题 function pay_order($order_id) { $this->load->helper('url'); //loading url helper $this->

重定向后会话值丢失。我正在从pay_order方法重定向到do_支付方法。当我在do_payment method中打印会话值时,其返回值为false。只需简单调用do_payment方法即可显示会话值。请帮助重定向有什么问题

function pay_order($order_id)

{
                 $this->load->helper('url'); //loading url helper    
                 $this->load->library('session');//loading session lib
                 $this->load->library('cart'); //loading cart lib
                 $this->load->helper('form');//loading form helper
                 $output = $this->cart->contents();// getting data from cart.
                 $output = $this->sort_array($output);// sorting the array
                 $list['data'] = $output;
                 $list['order_id'] = $order_id;
                 $this->session->set_userdata('abc', $list);// setting the session
                 redirect('checkout/do_payment'); // redirecting to do_payment

    }
    function do_payment() 
    {

             $this->load->helper('url'); //loading url helper
             $this->load->library('session'); //loading session library
             $arr = $this->session->userdata('abc');// getting session data in $arr
             var_dump( $arr );// return false value.
             //$this->load->view('order/pay_through_gateway');
    }

当我从pay_order方法重定向时,该会话在do_payment方法中不可用。为什么?

出现问题,请检查设置会话的方法
pay\u order()
中的行

$list['order_id'] = $order_id
$this->session->set_userdata('abc', $list);// setting the session
在那一行之前,你漏掉了分号。一切看起来都很好

更新:

正如我所想,没有错误,请检查在会话中存储值时是否有空值。并按照
do\u payment()
方法中的代码检查值

function do_payment(){
    $this->load->library('session'); //loading session library
    $arr = $this->session->userdata('abc');// getting session data in $arr
    print_r( $arr );// print the $arr content
}
更改此项:

$list['order_id'] = $order_id
为此:

$list['order_id'] = $order_id;

您缺少一个分号。由于重定向,您看不到任何错误。

Ritesh指出的是。和-您正在将购物车内容放入会话?是的,我正在将购物车项目放入会话?但重定向后无法获取所有这些内容。@MuhammadDanish on method
do\u payment
将会话显示为这样的
print\r($this->session->userdata)并向我们显示resultscodeigniter为购物车项目创建和维护会话。您必须设置一个db会话表。看一下手册:我知道codeigniter在会话中保存购物车数据。对于会话数据,我还添加了一些其他信息并保存在会话中。我没有丢失分号。在提问时被我错误地删除了。我没有遗漏分号。在提问时被我错误删除。代码现在运行良好。我已清除浏览器数据。可能是因为cookies Conflict发生了这件事。但是当我使用session_数据作为session对象的名称时。它也不会存储会话。