gongpex Posted July 25, 2015 Share Posted July 25, 2015 Hello everyone usually on codeigniter to retrieve value we use: $this->session->userdata('sessionname'); and value from this session can be displayed on class moreover on views for example : class example extends CI_Controller { function __construct() { } function example() { if($this->session->userdata == 0) { echo 'ok'; } else { echo 'no'; } $data['value'] = this->session->userdata('sessionname'); } } but how to get value from native session data generated by views ? for example : $qty = $_SESSION['cart'][$p_id]['quantity']; so that, on class it can be displayed like this : class example extends CI_Controller { function __construct() { } function example() { if($_SESSION['cart'][$p_id]['quantity'] == 0) { echo 'ok'; } else { echo 'no'; } $data['value'] = $_SESSION['cart'][$p_id]['quantity']; } } I had try to retrieve / get value from $_SESSION[] on class but it didn't work. Q : What I must do so that I can retrieve value from $_SESSION[], so that I can insert them into database using function $this->db->insert('nameDB',$data); please help me Thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted July 27, 2015 Share Posted July 27, 2015 I don't have any experience using Codeigniter, and I'm sure you could do some research to find some of those answers, but you can also just use their method and name your session values something like 'cart_' . $p_id . '_quantity' Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now