Esempio n. 1
0
 /**
  * Sets the session ID variable & the cookie
  *
  * @author Art <*****@*****.**>
  * @return string The generated ID
  */
 protected function setID()
 {
     $c = Alo::nullget($_COOKIE[$this->config->cookie]);
     //@codeCoverageIgnoreStart
     if ($c && strlen($c) == strlen(hash($this->config->sessionAlgo, 1))) {
         $sid = $c;
     } else {
         //@codeCoverageIgnoreEnd
         do {
             $sid = Alo::getUniqid($this->config->sessionAlgo, 'session' . Alo::getFingerprint('md5'));
         } while ($this->idExists($sid));
     }
     session_id($sid);
     $this->log->debug('Session ID set to ' . $sid);
     return $sid;
 }
Esempio n. 2
0
 /**
  * Creates and returns a token
  *
  * @author Art <*****@*****.**>
  *
  * @param string $hash Hash algorithm to use for the token
  *
  * @return string|null
  */
 public function create($hash = 'sha256')
 {
     if (!Sess::isActive()) {
         self::sessionRequiredWarning(__METHOD__);
         // @codeCoverageIgnoreStart
         return null;
         // @codeCoverageIgnoreEnd
     }
     $entry =& $_SESSION[$this->tokenKey];
     if (!Alo::get($entry) || !is_array($entry)) {
         $entry = [];
     }
     $entry[$this->name] = Alo::getUniqid($hash, __METHOD__);
     return $entry[$this->name];
 }