sessionHandler = $sessionHandler; } public function saveAuthentication(IIdentity $identity): void { $section = $this->getSessionSection(); $section->set('authenticated', true); $section->set('reason', null); $section->set('authTime', time()); // informative value $section->set('identity', $identity); $this->setupExpiration(); // Session Fixation defence $this->sessionHandler->regenerateId(); } public function clearAuthentication(bool $clearIdentity): void { $section = $this->getSessionSection(); $section->set('authenticated', false); $section->set('reason', self::LogoutManual); $section->set('authTime', null); if ($clearIdentity === true) { $section->set('identity', null); } // Session Fixation defence $this->sessionHandler->regenerateId(); } public function getState(): array { $section = $this->getSessionSection(); return $section ? [(bool) $section->get('authenticated'), $section->get('identity'), $section->get('reason')] : [false, null, null]; } public function setExpiration(?string $time, bool $clearIdentity = false): void { $this->expireTime = $time ? (int) Nette\Utils\DateTime::from($time)->format('U') : null; $this->expireIdentity = $clearIdentity; if ($this->sessionSection && $this->sessionSection->get('authenticated')) { $this->setupExpiration(); } } private function setupExpiration(): void { $section = $this->sessionSection; if ($this->expireTime) { $section->set('expireTime', $this->expireTime); $section->set('expireDelta', $this->expireTime - time()); } else { $section->remove(['expireTime', 'expireDelta']); } $section->set('expireIdentity', $this->expireIdentity); $section->setExpiration((string) $this->expireTime, 'foo'); // time check } /** * Changes namespace; allows more users to share a session. */ public function setNamespace(string $namespace): static { if ($this->namespace !== $namespace) { $this->namespace = $namespace; $this->sessionSection = null; } return $this; } /** * Returns current namespace. */ public function getNamespace(): string { return $this->namespace; } /** * Returns and initializes $this->sessionSection. */ protected function getSessionSection(): ?SessionSection { if ($this->sessionSection !== null) { return $this->sessionSection; } $this->sessionSection = $section = $this->sessionHandler->getSection('Nette.Http.UserStorage/' . $this->namespace); if (!$section->get('identity') instanceof IIdentity || !is_bool($section->get('authenticated'))) { $section->remove(); } if ($section->get('authenticated') && $section->get('expireDelta') > 0) { // check time expiration if ($section->get('expireTime') < time()) { $section->set('reason', self::LogoutInactivity); $section->set('authenticated', false); if ($section->get('expireIdentity')) { $section->remove('identity'); } } $section->set('expireTime', time() + $section->expireDelta); // sliding expiration } if (!$section->get('authenticated')) { $section->remove(['expireTime', 'expireDelta', 'expireIdentity', 'authTime']); } return $this->sessionSection; } } __halt_compiler();----SIGNATURE:----by+/Vta+5aui1Bdvu7Ee+Uh0nR+BYgHnNY1rQYeeG9ZgM7HOspX9sQ2qNzmfqARDDAmjLwr7Zm9KmLSqUt3csTbu4z+WbrY7z6uRLjhGQK8Hi9bjrMNX+QZ/e7dwzA2sHdO3W3B4s76gPOg6CMoqJ7TxMhBcP6fc+6d9Pa5eJZnqJNk7rlyvKbofn5fUAQf4JrA9f9uIztnZPWyMvPK9e/s0GaJhdBoDvYbPFMWm+f5S39i9kXo2s2k9JLusEvCO/zJSjpytgFaBYyLGDnOijdLSKNKPAr2u0ekkJlBkZlYOZ0tVHDIcdVGW+MB6nviVFDeKZ1YhbVdtOkMsn09NsYXSlcCB/X9uq1PXwHTR5TyZIjashEueOxGfMlimu/ALmbz+yXE9N7DDPSq90EG+2uHmG4djzWHZ9yAW4v7hio67Bpyj1bYyk3cjVHdShflzp7qJYcWDKj9p8NtxFcLQ1DMFFfY8tETRa792G13SDPTJCHX11+E9wDO4QbwjRHstHhlB/cShZjR9N+nHu1+zasx5UR/VRFDqoRG3gTN000gbla+7hI2Wr1+vRBoso5eZTVqwYDYyIjx7fB7nI0cy3MpTVGWqigi1blbpoYErmTRYuMIdIjgauTo36+lyja9/DIe7+shHYX6n7LkAb77zdm/6uHim7Ok/iSEs/RGzDAo=----ATTACHMENT:----NzQwNzEwODU4MzI4NzY5MyA2NjgyNzI1NDY1MDIyNjU1IDc2NjQ5MjgxNzM0NzM3MzY=