当前位置: 首页>>代码示例>>PHP>>正文


PHP SessionInterface::isStarted方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpFoundation\Session\SessionInterface::isStarted方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionInterface::isStarted方法的具体用法?PHP SessionInterface::isStarted怎么用?PHP SessionInterface::isStarted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpFoundation\Session\SessionInterface的用法示例。


在下文中一共展示了SessionInterface::isStarted方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle

 /**
  * {@inheritdoc}
  */
 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     // always set the session onto the request object.
     $request->setSession($this->session);
     // we only need to manage the session for the master request.
     // subrequests will have the session available anyways, but we will
     // be closing and setting the cookie for the master request only.
     if ($type !== HttpKernelInterface::MASTER_REQUEST) {
         return $this->kernel->handle($request, $type, $catch);
     }
     // the session may have been manually started before the middleware is
     // invoked - in this case, we cross our fingers and hope the session has
     // properly initialised itself
     if (!$this->session->isStarted()) {
         $this->initSession($request);
     }
     $response = $this->kernel->handle($request, $type, $catch);
     // if the session has started, save it and attach the session cookie. if
     // the session has not started, there is nothing to save and there is no
     // point in attaching a cookie to persist it.
     if ($this->session->isStarted()) {
         $this->closeSession($request, $response);
     }
     return $response;
 }
开发者ID:autarky,项目名称:framework,代码行数:28,代码来源:SessionMiddleware.php

示例2: getData

 /**
  * {@inheritdoc}
  */
 public function getData($key, $default = null)
 {
     if (!$this->session->isStarted()) {
         return $default;
     }
     return $this->session->get($key, $default);
 }
开发者ID:Avazanga1,项目名称:Sylius,代码行数:10,代码来源:SessionStorage.php

示例3: getHost

 /**
  * @return string
  */
 public function getHost()
 {
     if ($this->session->isStarted() && $this->session->has(self::OVERRIDE_HOST)) {
         return $this->session->get(self::OVERRIDE_HOST);
     }
     return parent::getHost();
 }
开发者ID:Amrit01,项目名称:KunstmaanBundlesCMS,代码行数:10,代码来源:DomainConfiguration.php

示例4: onResponse

 /**
  * Add the session cookie to the response if it is started.
  *
  * @param FilterResponseEvent $event
  */
 public function onResponse(FilterResponseEvent $event)
 {
     if (!$event->isMasterRequest() || !$this->session->isStarted()) {
         return;
     }
     $this->session->save();
     $cookie = $this->generateCookie();
     $event->getResponse()->headers->setCookie($cookie);
 }
开发者ID:nbehier,项目名称:bolt,代码行数:14,代码来源:SessionListener.php

示例5: onSiteAccessMatch

 public function onSiteAccessMatch(PostSiteAccessMatchEvent $event)
 {
     if (!($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST && isset($this->session) && !$this->session->isStarted() && $this->sessionStorage instanceof NativeSessionStorage)) {
         return;
     }
     $sessionOptions = (array) $this->configResolver->getParameter('session');
     $sessionName = isset($sessionOptions['name']) ? $sessionOptions['name'] : $this->session->getName();
     $sessionOptions['name'] = $this->getSessionName($sessionName, $event->getSiteAccess());
     $this->sessionStorage->setOptions($sessionOptions);
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:10,代码来源:SessionSetDynamicNameListener.php

示例6: getConfig

 public function getConfig()
 {
     $sessionInfo = ['isStarted' => false];
     if ($this->session->isStarted()) {
         $sessionInfo['isStarted'] = true;
         $sessionInfo['name'] = $this->session->getName();
         $sessionInfo['identifier'] = $this->session->getId();
         $sessionInfo['csrfToken'] = $this->csrfTokenManager->getToken($this->csrfTokenIntention)->getValue();
         $sessionInfo['href'] = $this->generateUrl('ezpublish_rest_deleteSession', ['sessionId' => $this->session->getId()]);
     }
     return $sessionInfo;
 }
开发者ID:yed30,项目名称:PlatformUIBundle,代码行数:12,代码来源:SessionInfo.php

示例7: onSiteAccessMatch

 public function onSiteAccessMatch(PostSiteAccessMatchEvent $event)
 {
     if (!$this->session || $event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
         return;
     }
     $sessionName = $this->session->getName();
     $request = $event->getRequest();
     if (!$this->session->isStarted() && !$request->hasPreviousSession() && $request->request->has($sessionName)) {
         $this->session->setId($request->request->get($sessionName));
         $this->session->start();
     }
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:12,代码来源:SessionInitByPostListener.php

示例8: onKernelException

 /**
  * Handle errors thrown in the application.
  *
  * @param GetResponseForExceptionEvent $event
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     $hasUser = $this->session->isStarted() && $this->session->has('authentication');
     if (!$hasUser && !$this->showWhileLoggedOff) {
         return;
     }
     $exception = $event->getException();
     ob_start();
     $this->whoops->handleException($exception);
     $response = ob_get_clean();
     $code = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : Response::HTTP_INTERNAL_SERVER_ERROR;
     $event->setResponse(new Response($response, $code));
 }
开发者ID:jkaan,项目名称:timOnlineBolt,代码行数:18,代码来源:WhoopsListener.php

示例9: getSessionId

 /**
  * @return string
  */
 public function getSessionId()
 {
     try {
         if ($this->startSession && !$this->session->isStarted()) {
             $this->session->start();
         }
         if ($this->session->isStarted()) {
             return $this->session->getId();
         }
     } catch (\RuntimeException $e) {
     }
     return self::SESSION_ID_UNKNOWN;
 }
开发者ID:Hexanet,项目名称:MonologExtraBundle,代码行数:16,代码来源:SymfonySessionIdProvider.php

示例10: onKernelException

 /**
  * Handle errors thrown in the application.
  *
  * Note:
  *   - We don't want to show Whoops! screens for requests that trigger a 404.
  *   - Our priority is set just above Symfony's, as we are giving up and
  *     displaying the error to the user, so that should be a low priority
  *     compared to error handlers that do something else.
  *
  * @param GetResponseForExceptionEvent $event
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     // We (generally) do not want to show Whoops! screens when the user isn't logged on.
     $hasUser = $this->session->isStarted() && $this->session->has('authentication');
     if (!$hasUser && !$this->showWhileLoggedOff) {
         return;
     }
     // Register Whoops as an error handler
     $this->whoops->register();
     $exception = $event->getException();
     ob_start();
     $this->whoops->handleException($exception);
     $response = ob_get_clean();
     $code = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : Response::HTTP_INTERNAL_SERVER_ERROR;
     $event->setResponse(new Response($response, $code));
 }
开发者ID:robbert-vdh,项目名称:bolt,代码行数:27,代码来源:WhoopsListener.php

示例11: isValidSession

 /**
  * We will not allow tampering with sessions, so we make sure the current
  * session is still valid for the device on which it was created, and that
  * the username, and IP address, are still the same.
  *
  * 1. If user has a valid session and it is fresh, check against cookie:
  *    - If NOT a match refuse
  *    - If a match accept
  * 2. If user has a valid session and it is stale (>10 minutes), check the
  *    database records again:
  *    - If disabled refuse
  *    - If enabled
  *      - If NOT a match refuse
  *      - If a match accept
  *      - Update session data
  * 3. If user has no session check authtoken table entry (closed broswer):
  *    - If passed validity date refuse
  *    - If within validity date, hash username and IP against salt and
  *      compare to database:
  *      - If NOT a match refuse
  *      - If a match accept
  *
  * @param string $authCookie
  *
  * @throws AccessControlException
  *
  * @return boolean
  */
 public function isValidSession($authCookie)
 {
     if ($authCookie === null) {
         throw new AccessControlException('Can not validate session with an empty token.');
     }
     if ($this->validSession !== null) {
         return $this->validSession;
     }
     $check = false;
     $sessionAuth = null;
     /** @var \Bolt\AccessControl\Token\Token $sessionAuth */
     if ($this->session->isStarted() && ($sessionAuth = $this->session->get('authentication'))) {
         $check = $this->checkSessionStored($sessionAuth);
     }
     if (!$check) {
         // Either the session keys don't match, or the session is too old
         $check = $this->checkSessionDatabase($authCookie);
     }
     if ($check) {
         return $this->validSession = true;
     }
     $this->validSession = false;
     $this->systemLogger->debug("Clearing sessions for expired or invalid token: {$authCookie}", ['event' => 'authentication']);
     return $this->revokeSession();
 }
开发者ID:robbert-vdh,项目名称:bolt,代码行数:53,代码来源:AccessChecker.php

示例12: removeToken

 /**
  * {@inheritdoc}
  */
 public function removeToken($tokenId)
 {
     if (!$this->session->isStarted()) {
         $this->session->start();
     }
     return $this->session->remove($this->namespace . '/' . $tokenId);
 }
开发者ID:ayoah,项目名称:symfony,代码行数:10,代码来源:SessionTokenStorage.php

示例13: initializeLegacySessionAccess

 /**
  * Initializes session access for $_SESSION['FE_DATA'] and $_SESSION['BE_DATA'].
  */
 private function initializeLegacySessionAccess()
 {
     if (!$this->session->isStarted()) {
         return;
     }
     $_SESSION['BE_DATA'] = $this->session->getBag('contao_backend');
     $_SESSION['FE_DATA'] = $this->session->getBag('contao_frontend');
 }
开发者ID:jamesdevine,项目名称:core-bundle,代码行数:11,代码来源:ContaoFramework.php

示例14: getSafeTrace

 /**
  * Get the exception trace that is safe to display publicly
  *
  * @param Exception $exception
  *
  * @return array
  */
 protected function getSafeTrace(Exception $exception)
 {
     if (!$this->isDebug && !($this->session->isStarted() && $this->session->has('authentication'))) {
         return [];
     }
     $trace = $exception->getTrace();
     foreach ($trace as $key => $value) {
         if (!empty($value['file']) && strpos($value['file'], '/vendor/') > 0) {
             unset($trace[$key]['args']);
         }
         // Don't display the full path.
         if (isset($trace[$key]['file'])) {
             $trace[$key]['file'] = str_replace($this->rootPath, '[root]/', $trace[$key]['file']);
         }
     }
     return $trace;
 }
开发者ID:atiarda,项目名称:bolt,代码行数:24,代码来源:ExceptionListener.php

示例15: __construct

 public function __construct(SessionInterface $session)
 {
     if ($session->isStarted()) {
         $this->session = $session;
     } else {
         $sessionClass = get_class($session);
         $this->session = new $sessionClass(new PhpBridgeSessionStorage());
     }
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:9,代码来源:PagePreference.php


注:本文中的Symfony\Component\HttpFoundation\Session\SessionInterface::isStarted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。