PHP Ferrari PHP Ferrari - 26 days ago 14
PHP Question

Codeigniter 2.1 : push more new value in session array every time

I my CI application I hit an ajax button, call controller action and want to push new value in already existing session array on every hit. I google but file.

Following are the sources which I tried.

add value into userdata array

Session Array Update in codeigniter

Answer

Okay I did it :

1- first load old array 2- push new value to array 3- set session

$old_que_ans_session =  $this->session->userdata('que_ans_session');
array_push($old_que_ans_session, $qIds[$_POST['my_que_no']]);
$this->session->set_userdata('que_ans_session', $old_que_ans_session);
Comments