Php 如何在会话结束后编辑会话';他创造了

Php 如何在会话结束后编辑会话';他创造了,php,session,phalcon,Php,Session,Phalcon,我正在使用Phalcon PHP,我想在创建会话后向会话中添加另一项。我有这个: private function _registerSession($user, $account) { $this->session->set('auth', array( 'user_id' => $user->id, 'username' => $user->name )); } 在另一个控制器中,我要编辑此会话,例如: $

我正在使用Phalcon PHP,我想在创建会话后向会话中添加另一项。我有这个:

private function _registerSession($user, $account) {
    $this->session->set('auth', array(
        'user_id' => $user->id,
        'username' => $user->name
    )); }
在另一个控制器中,我要编辑此会话,例如:

$auth = $this->session->get('auth');
$auth->add('account_id', '10');
本课程将包含以下三个变量:

    $this->session->set('auth', array(
        'user_id' => $user->id,
        'username' => $user->name,
        'account_id' => 10
    )); }
但我不知道我如何才能做到这点。

这应该可以:

private function _registerSession($user, $account) {
    $this->session->set_userdata('auth', array(
        'user_id' => $user->id,
        'username' => $user->name
    )); }

// You should use the following code to set one more parameter in sesssion:

   $this->session->set_userdata('auth', array(
        'user_id' => $this->session_userdata('user_id'),
        'username' => $this->session_userdata('username'),
        'account_id' => 10
    ));
$auth = $this->session->get("auth");
$this->session->set("auth", array_merge($auth, array('account_id'=>'10')));
这应该起作用:

$auth = $this->session->get("auth");
$this->session->set("auth", array_merge($auth, array('account_id'=>'10')));

我想你可以这样使用:-

$auth = $this->session->get('auth'); 
$auth['account_id']= 10;
$this->session->set('auth',$auth);

我想你可以这样使用:-

$auth = $this->session->get('auth'); 
$auth['account_id']= 10;
$this->session->set('auth',$auth);

您需要按照以下方式进行操作:-

$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

您需要按照以下方式进行操作:-

$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

Phalcon的会话代码只是
$\u session
的包装器。最简单的解决方案是避免使用Phalcon函数:

$_SESSION['auth']->add('account_id',10);

Phalcon的会话代码只是
$\u session
的包装器。最简单的解决方案是避免使用Phalcon函数:

$_SESSION['auth']->add('account_id',10);

这不起作用:PHP致命错误:对非对象调用成员函数集()
$auth=$This->session->get('auth')$认证['account_id']=“10”$此->会话->设置('auth',$auth)完美!非常感谢:)这不起作用:PHP致命错误:对非对象调用成员函数集()
$auth=$This->session->get('auth')$认证['account_id']=“10”$此->会话->设置('auth',$auth)完美!非常感谢:)欢迎@John.ThanksWelcome@John.ThanksWelcome