Пример #1
0
 public function load()
 {
     $data = $this->sessionProvider->read($this->sessionKey);
     if ($data) {
         try {
             $unserialized = unserialize($data);
             if (is_array($unserialized)) {
                 $this->currentData = $unserialized;
             }
         } catch (Exception $e) {
         }
     }
     $this->sessionProvider->remove($this->sessionKey);
 }
Пример #2
0
 public function loginUserFromSession()
 {
     if (!$this->enabled) {
         return false;
     }
     if ($this->isLoggedIn()) {
         return true;
     }
     $userId = $this->sessionProvider->read($this->sessionKey);
     if ($userId) {
         $sql = " SELECT * from {$this->tableUser} WHERE {$this->columnId} = {$userId} Limit 1";
         $query = $this->dbProvider->query($sql);
         $user = $this->dbProvider->row($query);
         if ($user) {
             $this->user = $user;
             $this->userId = $user->{"" . $this->columnId};
             $updateSql = "Update {$this->tableUser} SET {$this->columnDateLastLogin} = '" . date('Y-m-d H:i:s') . "' Where {$this->columnId} = {$this->userId}";
             $this->dbProvider->query($updateSql);
             return true;
         } else {
             return false;
         }
     }
 }