Exemple #1
0
 /**
  * Check if user is logged
  * 
  * @return boolean
  */
 public function check()
 {
     $output = false;
     if (!empty($_COOKIE['login'])) {
         //v cookie je session hash, s dalsimi pridavkami to overime v DB
         $userData = $this->mUsers->getBySession($_SERVER['REMOTE_ADDR'] . ' ' . $_COOKIE['login']);
         if (!empty($userData)) {
             $_SESSION[self::SESSION_KEY] = array('idUser' => $userData['idUser'], 'nick' => $userData['nick']);
             $output = true;
         }
     } elseif (isset($_SESSION[self::SESSION_KEY]['time']) and $_SESSION[self::SESSION_KEY]['time'] >= time() - 3600) {
         $output = true;
     }
     if ($output) {
         $_SESSION[self::SESSION_KEY]['time'] = time();
         $this->updateSession();
     } else {
         $this->logout();
     }
     return $output;
 }