Ben
Ben

Reputation: 4462

Codeigniter append existing session

How to append a new value to the existing session in codeigniter without retrieve session data and reassign the values?

I have a session like this:

$sess = array('a'=>1,'b'=>1);

$this->session->set_userdata('my_session',$sess);

I want to append an array 'array('p'=>1,'q'=>2)' to my existing session named 'my_session'

Any idea?

(if not clear please comment)

Upvotes: 0

Views: 2220

Answers (1)

Code Prank
Code Prank

Reputation: 4250

You may use
$this->session->set_userdata('variable_name', 'some_value');
if your variable already exists in the session its value will be reassigned other wise a new variable will be created.

Upvotes: 2

Related Questions