Q:

How to edit a session after it's created

I'm using Phalcon PHP and I want to add another item to my session after it's created. I have this :
private function _registerSession($user, $account) {
    $this->session->set('auth', array(
        'user_id' => $user->id,
        'username' => $user->name
    )); }

In another controller I want to edit this session for example :
$auth = $this->session->get('auth');
$auth->add('account_id', '10');

And this session will content the 3 variables as :
    $this->session->set('auth', array(
        'user_id' => $user->id,
        'username' => $user->name,
        'account_id' => 10
    )); }

But I don't know how I can dot that.

A:

Yo need to do it in following manner:-
$auth = $this->session->get('auth'); // get auth array from Session
$auth['account_id']= '10'; // add new index value pair to it
$this->session->set('auth',$auth); // reassign it to auth index of Session

