【发布时间】:2016-01-01 04:26:01
【问题描述】:
我有一个页面,我可以在其中修改用户详细信息(用户名、名字、头像...)。 我的导航栏中有一个元素,其中包含有关当前登录用户的信息。问题是我不知道如何在修改数据后立即刷新会话。
在UsersController中:
public function edit($id = null)
{
if (!$id) {
throw new NotFoundException(__('Invalid user'));
}
$user = $this->Users->get($id);
if ($this->request->is(['post', 'put'])) {
$this->Users->patchEntity($user, $this->request->data);
if ($this->Users->save($user)) {
//REFRESH SESSION ????\\
$this->request->session()->write('Auth.User', $user);
//\\
$this->Flash->success(__('User has been updated.'));
return $this->redirect(['action' => 'edit/' . $id]);
}
$this->Flash->error(__('Unable to update User details.'));
}
$this->set(compact('user'));
}
【问题讨论】:
标签: php session cakephp cakephp-3.0