/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/Auth/Storage
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/Auth/Storage/SessionStorage.php (3722B)
*/
protected $_defaultConfig = [
'key' => 'Auth.User',
'redirect' => 'Auth.redirect',
];
/**
* Constructor.
*
* @param \Cake\Http\ServerRequest $request Request instance.
* @param \Cake\Http\Response $response Response instance.
* @param array
$config Configuration list.
*/
public function __construct(ServerRequest $request, Response $response, array $config = [])
{
$this->_session = $request->getSession();
$this->setConfig($config);
}
/**
* Read user record from session.
*
* @return \ArrayAccess|array|null User record if available else null.
* @psalm-suppress InvalidReturnType
*/
public function read()
{
if ($this->_user !== null) {
return $this->_user ?: null;
}
/** @psalm-suppress PossiblyInvalidPropertyAssignmentValue */
$this->_user = $this->_session->read($this->_config['key']) ?: false;
/** @psalm-suppress InvalidReturnStatement */
return $this->_user ?: null;
}
/**
* Write user record to session.
*
* The session id is also renewed to help mitigate issues with session replays.
*
* @param \ArrayAccess|array $user User record.
* @return void
*/
public function write($user): void
{
$this->_user = $user;
$this->_session->renew();
$this->_session->write($this->_config['key'], $user);
}
/**
* Delete user record from session.
*
* The session id is also renewed to help mitigate issues with session replays.
*
* @return void
*/
public function delete(): void
{
$this->_user = false;
$this->_session->delete($this->_config['key']);
$this->_session->renew();
}
/**
* @inheritDoc
*/
public function redirectUrl($url = null)
{
if ($url === null) {
return $this->_session->read($this->_config['redirect']);
}
if ($url === false) {
$this->_session->delete($this->_config['redirect']);
return null;
}
$this->_session->write($this->_config['redirect'], $url);
return null;
}
}