當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。