user3507747
user3507747

Reputation: 29

retrieving data from last id and storing in session in codeigniter

I like to receive the value of a particular row by using my last inserted id. and store it in session. but I feel problem. Would anyone help me please?

Controllers:

public function save_client() {

     $data = array();
     $data['client_first_name'] = $this->input->post('client_first_name', true);
     $data['client_last_name'] = $this->input->post('client_last_name', true);


     $data['client_email_address'] = $this->input->post('client_email_address', true);
     $data['client_password'] = $this->input->post('client_password1', true);

     $client_id= $this->w_list_model->save_client_info($data);

     $sdata = array();

     $sdata['client_id'] = $client_id;
     //here is my problem

     $sdata['client_first_name'] = $client_first_name;
     $sdata['client_last_name'] = $client_last_name;
     $sdata['login_status'] = true;
     $this->session->set_userdata($sdata);
        redirect('welcome/see_details');
     }

I cannot store the additional value (except client_id) in session data.

Models

public function save_client_info($data) {
            $this->db->insert('tbl_client', $data);
            $client_id = $this->db->insert_id();
            return $client_id;
        }

Upvotes: 0

Views: 183

Answers (1)

jleft
jleft

Reputation: 3457

You should just be able to use the post data, as the values would be the same as retrieving it from the database:

$sdata['client_first_name'] = $data['client_first_name'];
$sdata['client_last_name']  = $data['$client_last_name'];

Upvotes: 1

Related Questions