Example #1
0
 /**
  * Returns and initializes $this->sessionSection.
  * @return SessionSection
  */
 protected function getSessionSection($need)
 {
     if ($this->sessionSection !== NULL) {
         return $this->sessionSection;
     }
     if (!$need && !$this->sessionHandler->exists()) {
         return NULL;
     }
     $this->sessionSection = $section = $this->sessionHandler->getSection('Nette.Http.UserStorage/' . $this->namespace);
     if (!$section->identity instanceof IIdentity || !is_bool($section->authenticated)) {
         $section->remove();
     }
     if ($section->authenticated && $section->expireBrowser && !$section->browserCheck) {
         // check if browser was closed?
         $section->reason = self::BROWSER_CLOSED;
         $section->authenticated = FALSE;
         if ($section->expireIdentity) {
             unset($section->identity);
         }
     }
     if ($section->authenticated && $section->expireDelta > 0) {
         // check time expiration
         if ($section->expireTime < time()) {
             $section->reason = self::INACTIVITY;
             $section->authenticated = FALSE;
             if ($section->expireIdentity) {
                 unset($section->identity);
             }
         }
         $section->expireTime = time() + $section->expireDelta;
         // sliding expiration
     }
     if (!$section->authenticated) {
         unset($section->expireTime, $section->expireDelta, $section->expireIdentity, $section->expireBrowser, $section->browserCheck, $section->authTime);
     }
     return $this->sessionSection;
 }