isStarted() public method

Has been session started?
public isStarted ( ) : boolean
return boolean
コード例 #1
0
 /**
  * Html code for DebugerBar Panel
  * @author Pavel Železný <*****@*****.**>
  * @return string
  */
 public function getPanel()
 {
     $template = $this->getFileTemplate(__DIR__ . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'panel.latte');
     $template->session = $this->session->isStarted() ? $this->session : FALSE;
     $template->sessionMetaStore = isset($_SESSION['__NF']['META']) ? $_SESSION['__NF']['META'] : array();
     $template->sessionMaxTime = ini_get('session.gc_maxlifetime');
     $template->hiddenSections = $this->hiddenSections;
     return $template;
 }
コード例 #2
0
ファイル: CaptchaManager.php プロジェクト: kivi8/ars-poetica
 /**
  * Check if answer is corect
  * @param string $answer
  * @throws CookieException
  * @return bool
  */
 public function checkCaptcha($answer)
 {
     if (!$this->session->isStarted()) {
         throw new \Exception('Povolte cookies ve vašem prohlížeči');
     }
     if ($this->cutAnswer($answer) != $this->cutAnswer($this->sessSect->answer)) {
         $this->sessSect->status = 'answBad';
         throw new \Exception('Špatná odpověď na otázku, možná pouze špatně zapsaná');
     }
     $this->sessSect->status = 'answOk';
     return true;
 }
コード例 #3
0
 /**
  * @param Translator $translator
  * @return string|NULL
  */
 public function resolve(Translator $translator)
 {
     if (!$this->session->isStarted() && $this->httpResponse->isSent()) {
         trigger_error("The advice of session locale resolver is required but the session has not been started and headers had been already sent. " . "Either start your sessions earlier or disabled the SessionResolver.", E_USER_WARNING);
         return NULL;
     }
     if (empty($this->localeSession->locale)) {
         return NULL;
     }
     $short = array_map(function ($locale) {
         return substr($locale, 0, 2);
     }, $translator->getAvailableLocales());
     if (!in_array(substr($this->localeSession->locale, 0, 2), $short, TRUE)) {
         return NULL;
     }
     return $this->localeSession->locale;
 }
コード例 #4
0
ファイル: SessionMailer.php プロジェクト: nextras/mail-panel
 /**
  * @return void
  */
 private function requireSessions()
 {
     if (!$this->session->isStarted()) {
         throw new \RuntimeException('Session is not started, start session or use FileMailer instead.');
     }
     if (!isset($this->sessionSection->messages)) {
         $this->sessionSection->messages = array();
     }
 }
コード例 #5
0
ファイル: TestCase.php プロジェクト: jirinapravnik/twitter
 public function __construct(Http\Session $session = NULL)
 {
     if ($session->isStarted()) {
         $session->destroy();
     }
     $session->setOptions(['cookie_disabled' => TRUE]);
 }
コード例 #6
0
 /**
  * Registers CaptchaControl to the \Nette\Forms\Container, starts session and sets $defaultFontFile (if not set)
  *
  * @param \Nette\Http\Session $session session
  * @throws \Nette\InvalidStateException
  * @return void
  */
 public static function register(Session $session)
 {
     if (self::$registered === TRUE) {
         throw new InvalidStateException(__CLASS__ . ' is already registered.');
     }
     if ($session->isStarted() === FALSE) {
         $session->start();
     }
     self::$session = $session->getSection(__CLASS__);
     if (!self::$defaultFontFile) {
         self::$defaultFontFile = __DIR__ . '/fonts/Vera.ttf';
     }
     Container::extensionMethod('addCaptcha', function ($container, $name) {
         return $container[$name] = new static();
     });
     self::$registered = TRUE;
 }
コード例 #7
0
 /**
  * Register CaptchaControl to FormContainer, start session and set $defaultFontFile (if not set)
  * @return void
  * @throws \Nette\InvalidStateException
  */
 public static function register(Session $session)
 {
     if (self::$registered) {
         throw new \Nette\InvalidStateException(__CLASS__ . " is already registered");
     }
     if (!$session->isStarted()) {
         $session->start();
     }
     self::$session = $session->getSection(__CLASS__);
     if (!self::$defaultFontFile) {
         self::$defaultFontFile = __DIR__ . "/fonts/Vera.ttf";
     }
     FormContainer::extensionMethod('addCaptcha', callback(__CLASS__, 'addCaptcha'));
     self::$registered = TRUE;
 }