I want to store two dimensional array in session, where i keep creating the array through a function call.
I am trying with this code
function nextQuestion($questionId,$response)
{
$this->session->set_userdata("res[$questionId][]"),$response);
}
but this is not creating a two dimensional array
The key stored in the session must be a string but the value can be a multi dimensional array.
You can retrieve the array, manipulate it and save it in the session again like this:
$session_response = $this->session->userdata("res");
//some manipulation on $session_response
$this->session->set_userdata('res', $session_response);
sametimes codeigniter session library can be boring.
if i add array to session, i serialize the array.
You can serialize array and get back with unserialize. or you can use php session library.