Пример #1
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new static();
         $_SESSION = self::$instance;
         // read the session data
         $_SESSION->readData();
         //earliest possible point to set debugging according to session.
         $_SESSION->restoreDebuggingParams();
         $_SESSION->cmsSessionExpand();
     }
     return self::$instance;
 }
Пример #2
0
 /**
  * Callable on session destroy
  *
  * @param string $aKey
  * @param boolean $destroyCookie
  * @return boolean
  */
 public function destroy($aKey = "", $destroyCookie = true)
 {
     if (empty($aKey)) {
         session_destroy();
         self::$instance = null;
     } else {
         $query = "DELETE FROM " . DBPREFIX . "sessions WHERE sessionid = '" . $aKey . "'";
         \Env::get('db')->Execute($query);
         $query = "DELETE FROM " . DBPREFIX . "session_variable WHERE sessionid = '" . $aKey . "'";
         \Env::get('db')->Execute($query);
         if (\Cx\Lib\FileSystem\FileSystem::exists($this->sessionPath)) {
             \Cx\Lib\FileSystem\FileSystem::delete_folder($this->sessionPath, true);
         }
         if ($destroyCookie) {
             setcookie("PHPSESSID", '', time() - 3600, '/');
         }
         // do not write the session data
         $this->discardChanges = true;
     }
     return true;
 }