Codeigniter session destroy after redirect
12,754
Solution 1
What is your configuration in application/config/config.php
If it is $config['sess_use_database'] = FALSE;
that means that you store session info in cookies, which is limited to 4kb. Probably that is the problem. Store large amount of data in database.
http://ellislab.com/codeigniter/user-guide/libraries/sessions.html
Solution 2
please remove the following line and try
$this->load->model('customer_model');
Solution 3
I have the same problem and solve it by disable check for session user agent:
$config['sess_match_useragent']=FALSE
Author by
Muhammad Danish
Updated on June 09, 2022Comments
-
Muhammad Danish almost 2 years
I am adding order id and cart items in session. if I add 2 cart items in session. It's works fine. If I add 3 or more items of cart in session. All the data after redirect lost. the name of controller is 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. }
snapshot before redirect is also attached.