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


PHP Session::isStarted方法代码示例

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


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

示例1: startSession

 /**
  * Starts the session if it does not exist.
  *
  * @return void
  */
 protected function startSession()
 {
     // Check that the session hasn't already been started
     if ($this->session->isStarted()) {
         $this->session->start();
     }
 }
开发者ID:Webapper,项目名称:silex-sentinel-service-provider,代码行数:12,代码来源:SilexSession.php

示例2: getSessionId

 /**
  * {@inheritdoc}
  */
 protected function getSessionId()
 {
     if (!$this->session->isStarted()) {
         $this->session->start();
     }
     return $this->session->getId();
 }
开发者ID:jacobjjc,项目名称:PageKit-framework,代码行数:10,代码来源:SessionCsrfProvider.php

示例3: isSessionStarted

 /**
  * {@inheritDoc}
  */
 public function isSessionStarted()
 {
     if (!$this->session->isStarted()) {
         $this->session->start();
     }
     return $this->session->isStarted();
 }
开发者ID:focuslife,项目名称:v0.1,代码行数:10,代码来源:SymfonyHttpDriver.php

示例4: onKernelResponse

 /**
  * Moves flash messages from the session to a cookie inside a Response Kernel listener.
  *
  * @param FilterResponseEvent $event
  */
 public function onKernelResponse(FilterResponseEvent $event)
 {
     if ($event->getRequestType() !== HttpKernel::MASTER_REQUEST) {
         return;
     }
     // Flash messages are stored in the session. If there is none, there
     // can't be any flash messages in it. $session->getFlashBag() would
     // create a session, we need to avoid that.
     if (!$this->session->isStarted()) {
         return;
     }
     $flashBag = $this->session->getFlashBag();
     $flashes = $flashBag->all();
     if (empty($flashes)) {
         return;
     }
     $response = $event->getResponse();
     $cookies = $response->headers->getCookies(ResponseHeaderBag::COOKIES_ARRAY);
     if (isset($cookies[$this->options['host']][$this->options['path']][$this->options['name']])) {
         $rawCookie = $cookies[$this->options['host']][$this->options['path']][$this->options['name']]->getValue();
         $flashes = array_merge($flashes, json_decode($rawCookie));
     }
     $cookie = new Cookie($this->options['name'], json_encode($flashes), 0, $this->options['path'], $this->options['host'], $this->options['secure'], false);
     $response->headers->setCookie($cookie);
 }
开发者ID:wickedOne,项目名称:FOSHttpCacheBundle,代码行数:30,代码来源:FlashMessageSubscriber.php

示例5: __construct

 public function __construct(Mysql $db, Session $session)
 {
     $this->db = $db;
     $this->session = $session;
     if (!$this->session->isStarted()) {
         $this->session->start();
     }
 }
开发者ID:jorions,项目名称:acashop,代码行数:8,代码来源:LoginService.php

示例6: __construct

 /**
  * Session constructor.
  *
  * @param string|null $namespace
  */
 public function __construct($namespace = null)
 {
     @session_start();
     $this->session = new SymfonySession(new PhpBridgeSessionStorage());
     if (!$this->session->isStarted()) {
         $this->session->start();
     }
     $this->setSessionValues($namespace);
 }
开发者ID:vmille,项目名称:TuleapRestApiBridge,代码行数:14,代码来源:Session.php

示例7: __construct

 public function __construct(Mysql $db, Session $session, LoginService $login)
 {
     $this->db = $db;
     $this->session = $session;
     $this->login = $login;
     if (!$this->session->isStarted()) {
         $this->session->start();
     }
 }
开发者ID:jorions,项目名称:acashop-OLD,代码行数:9,代码来源:ProfileService.php

示例8: indexAction

 /**
  * @Route("/", name="homepage")
  */
 public function indexAction(Request $request)
 {
     $session = new Session();
     if ($session->isStarted() == true) {
         $session->start();
     }
     $products = $this->getDoctrine()->getRepository('AppBundle:Product')->findAll();
     $prodId = $request->request->get('prod', 'noone');
     $inBasket[] = "Empty Basket, please select a product";
     if ($prodId != 'noone') {
         $product = $this->getDoctrine()->getRepository('AppBundle:Product')->find($prodId);
         $session->set($product->getId(), $product->getName());
         $log = new Log();
         $log->setProdName($product->getName());
         $log->setDate(new \DateTime());
         $em = $this->getDoctrine()->getManager();
         $em->persist($log);
         $em->flush();
         echo "Dev : Log saved to database. Product name - " . $product->getName() . " Current time - " . $log->getDate()->format('H:i:s \\O\\n Y-m-d');
         $inBasket = $session->all();
     } else {
         if ($session->count() != 0) {
             $inBasket = $session->all();
             echo "Please select a Product before submitting !!!";
         }
     }
     return $this->render('default/index.html.twig', ['products' => $products, 'basketProds' => $inBasket]);
 }
开发者ID:flech,项目名称:ZadITMore,代码行数:31,代码来源:DefaultController.php

示例9: generateTokenString

 /**
  * Generate token string
  */
 private function generateTokenString()
 {
     if ($this->session->isStarted() === false) {
         $this->session->start();
     }
     return sha1($this->secret . $this->session->getId());
 }
开发者ID:suin,项目名称:symfony2-csrf-firewall-bundle,代码行数:10,代码来源:FirewallListener.php

示例10: getSession

 public function getSession($request)
 {
     if (($session = $request->getSession()) === NULL) {
         $session = new Session();
     }
     if (!$session->isStarted()) {
         $session->start();
     }
     return $session;
 }
开发者ID:BoraxKid,项目名称:WSIPN,代码行数:10,代码来源:DefaultController.php

示例11: register

 /**
  * Register the service provider.
  *
  * @return object
  */
 public function register()
 {
     $this->app->singleton('session', function () {
         $storage = new NativeSessionStorage($this->getOptions(), $this->getHandler(), new MetadataBag());
         $session = new SfSession($storage, new AttributeBag('_group_attributes'), new FlashBag());
         if (!$session->isStarted()) {
             $session->start();
         }
         return new SessionService($session);
     });
 }
开发者ID:hellHI1,项目名称:Group,代码行数:16,代码来源:SessionServiceProvider.php

示例12: addMessage

 /**
  * @param $type
  * @param null $header
  * @param null $title
  * @param null $message
  * @param null $buttonMessage
  * @return bool
  */
 private function addMessage($type, $header = null, $title = null, $message = null, $buttonMessage = null)
 {
     if (!$this->flashBag && $this->session->isStarted()) {
         $this->flashBag = $this->session->getFlashBag();
     }
     if ($this->flashBag) {
         $this->flashBag->add($type, new FlashMessage($header, $title, $message, $buttonMessage));
         return true;
     }
     return false;
 }
开发者ID:NobletSolutions,项目名称:FlashBundle,代码行数:19,代码来源:Messages.php

示例13: applySessionStrategy

 /**
  * Apply the Session Strategy
  *
  * @return void
  */
 protected function applySessionStrategy()
 {
     if (!$this->session->isStarted()) {
         return $this->session->start();
     }
     switch ($this->strategy) {
         case self::STRATEGY_MIGRATE:
             $this->session->migrate();
             break;
         case self::STRATEGY_INVALIDATES:
             $this->session->invalidate();
             break;
         default:
             throw new \RuntimeException('Session strategy should be "migrate" or "invalidate"');
     }
 }
开发者ID:fwk,项目名称:security,代码行数:21,代码来源:SessionStorage.php

示例14: indexAction

 /**
  * @Route("/", name="homepage")
  */
 public function indexAction(Request $request)
 {
     $session = $request->getSession();
     if ($session == null) {
         $session = new Session();
     }
     if (!$session->isStarted()) {
         $session->start();
     }
     //new sessionID if session existed already.
     $session->migrate();
     if ($session->has('originalSessionID')) {
         $session->remove('originalSessionID');
     }
     return $this->render('default/index.html.twig');
 }
开发者ID:DanieleMenara,项目名称:CreateSafe,代码行数:19,代码来源:DefaultController.php

示例15: getLoginUrls

 public function getLoginUrls()
 {
     $socialNetworks = $this->socialNetworkRepository->findBy(array('enabled' => true, 'loginEnabled' => true));
     try {
         $session = new Session();
         if (!$session->isStarted()) {
             $session->start();
         }
     } catch (\Exception $e) {
     }
     $urls = array();
     $provider_prefix = "socialhub_provider_";
     foreach ($socialNetworks as $socialNetwork) {
         $socialProvider = $this->container->get($provider_prefix . $socialNetwork->getType());
         $loginUrl = $socialProvider->getLoginUrl();
         $urls[] = array('name' => $socialNetwork->getName(), 'type' => $socialNetwork->getType(), 'label' => "label." . $socialNetwork->getType(), 'url' => $loginUrl);
     }
     return $urls;
 }
开发者ID:flowcode,项目名称:socialhub,代码行数:19,代码来源:SocialNetworkService.php


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