Refresh session data / identity object

@KevinPfeifer Kevin Pfeifer
Thu, 05 Sep 2024 13:43:43 +0000

If you use the SessionAuthenticator then

$this->Authentication->setIdentity($user);

should keep the session values up2date. You just need to call it whenever the User gets updated.

github.com

cakephp/authentication/blob/3.x/src/Authenticator/SessionAuthenticator.php#L97

87.  * @inheritDoc


88.  */


89. public function persistIdentity(ServerRequestInterface $request, ResponseInterface $response, $identity): array


90. {


91.     $sessionKey = $this->getConfig('sessionKey');


92.     /** @var \Cake\Http\Session $session */


93.     $session = $request->getAttribute('session');





95.     if (!$session->check($sessionKey)) {


96.         $session->renew();


97.         $session->write($sessionKey, $identity);


98.     }





100.     return [


101.         'request' => $request,


102.         'response' => $response,


103.     ];


104. }





106. /**


107.  * @inheritDoc