【发布时间】:2016-01-21 12:55:01
【问题描述】:
我正在使用 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');
本次会议将包含 3 个变量:
$this->session->set('auth', array(
'user_id' => $user->id,
'username' => $user->name,
'account_id' => 10
)); }
但我不知道我该怎么做。
【问题讨论】:
-
这不起作用:PHP 致命错误:在非对象上调用成员函数 set()
-
$auth = $this->session->get('auth'); $auth['account_id']= '10';$this->session->set('auth',$auth); -
完美!非常感谢:)