2

So $token here is an array of data from the database, I would like to retrieve it in the view. I know that the data is already there by using print_r($this->session->all_userdata()); but I would like to retrieve the values from the $token array and use it.

Controller:

$token['answer']=$this->Qmodel->get_answers();
$data= array(
    'username' => $this->input->post('username'),
    'is_logged'=> 1,
    $token
);

$this->session->set_userdata($data);

1 Answer 1

1

You can try with this one,I hope it will help you

 $token['answer']=$this->Qmodel->get_answers();
    $data= array(
                'username' => $this->input->post('username'),
                'is_logged'=> 1,
                'token' => $token['answer'] // assign $token['answer'] array into token
                );

    $this->session->set_userdata($data);

get $token['answer'] array data from session:

$token_from_session = $this->session->userdata('token'); //return $token['answer'] array
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.