本文整理汇总了PHP中Nette\Http\Session::isStarted方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::isStarted方法的具体用法?PHP Session::isStarted怎么用?PHP Session::isStarted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Http\Session
的用法示例。
在下文中一共展示了Session::isStarted方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPanel
/**
* Html code for DebugerBar Panel
* @author Pavel Železný <info@pavelzelezny.cz>
* @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: checkCaptcha
/**
* 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: resolve
/**
* @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: requireSessions
/**
* @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: __construct
public function __construct(Http\Session $session = NULL)
{
if ($session->isStarted()) {
$session->destroy();
}
$session->setOptions(['cookie_disabled' => TRUE]);
}
示例6: register
/**
* 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: register
/**
* 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;
}