Am using codeigniter to build an eCommerce site.
I have a method on controller where users enter their delivery information before checkout, the method saves the delivery information and creates a new session variable called “orderid” which has the value of the orderid as its value. After setting the session variable the method redirects to the checkout controller where i retrieve the “orderid” from the session to retrieve the order from the db for the user to confirm the information before paying.
The problem is, when the user is redirected to the checkout page, they dont see their delivery data.
When do this
echo $this->session->userdata('orderid');
I can see the value
But when i pass it to my method that supposed to return an array of data
$order = $this->orders->get_order($this->session->userdata('orderid'));
print_r($order);
I get an empty array array()
When the checkout page is refreshed it behaves correctly.
What could be the problem
You cannot access session value like this
You can use the following method it ll be work fine for you
**please remembere load session library at constructor or in this function