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


PHP Session::get方法代码示例

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


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

示例1: getSessionVar

 /**
  * Returns a user var from the session.
  *
  * @param string $name
  * @param null $default
  *
  * @return mixed
  */
 public function getSessionVar($name, $default = null)
 {
     if (null === $this->session) {
         return $default;
     }
     return $this->session->get($name, $default);
 }
开发者ID:ekyna,项目名称:table,代码行数:15,代码来源:RequestHelper.php

示例2: onKernelRequest

 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($this->session->has('_locale')) {
         $event->getRequest()->setLocale($this->session->get('_locale'));
         $this->translator->setLocale($this->session->get('_locale'));
     }
 }
开发者ID:ChrisdAutume,项目名称:EtuUTT,代码行数:10,代码来源:LocaleListener.php

示例3: TableauAction

 /**
  * @Route("/ajax/tableau",name="ajaxtab")
  * @Template("coffreappBundle:Default:tableau.html.twig")
  */
 public function TableauAction()
 {
     $session = new Session();
     $em = $this->getDoctrine()->getManager();
     $entities = $em->getRepository('coffreappBundle:Ticket')->findBy(array('operateur' => $session->get('Codecaisse'), 'session' => $session->get('Session')), array('id' => "desc"));
     return array('entity' => $entities);
 }
开发者ID:Jrbebel,项目名称:GestionTitre,代码行数:11,代码来源:DefaultController.php

示例4: get

 /**
  * @param $name
  * @return Filter
  */
 public function get($name, $reset = false)
 {
     if (!$this->session->has('filter_' . $name) || $reset) {
         $this->session->set('filter_' . $name, new Filter());
     }
     return $this->session->get('filter_' . $name);
 }
开发者ID:jaapjansma,项目名称:homefinance,代码行数:11,代码来源:FilterBag.php

示例5: displayAction

 /**
  * @Route("/rezerwacja-biuro-podrozy", name="reserve")
  */
 public function displayAction(Request $request)
 {
     $conn = $this->get('database_connection');
     $session = new Session();
     $bool = 0;
     $msg = '';
     if ($session->has('offerId')) {
         $bool = 0;
         $oferta = $this->getDoctrine()->getRepository('AppBundle:Oferta')->findOneByIdOferta($session->get('offerId'));
     } else {
         $oferta = new Oferta();
         $bool = 1;
         $msg = 'Oferta nie istnieje!';
     }
     if ($request->getMethod() == 'POST' && $bool == 0) {
         $rezerwacja = new Rezerwacja();
         $konto = $this->getDoctrine()->getRepository('AppBundle:Konto')->findOneByLogin($session->get('name'));
         $rezerwacja->setIdKonto($konto);
         $rezerwacja->setKwota($oferta->getCena());
         $rezerwacja->setData(new \DateTime());
         $em = $this->getDoctrine()->getManager();
         $em->persist($rezerwacja);
         $em->flush();
         $msg = 'Dodano do rezerwacji!';
     }
     return $this->render('default/reserve.html.twig', array('bool' => $bool, 'message' => $msg, 'offer' => $oferta, 'session' => $session, 'base_dir' => realpath($this->container->getParameter('kernel.root_dir') . '/..')));
 }
开发者ID:Elleander,项目名称:BiuroPodrozyProject,代码行数:30,代码来源:ReserveController.php

示例6: __construct

 /**
  * CartProvider constructor.
  * @param Session $session
  * @param EntityManagerInterface $entityManager
  * @param $parameters
  */
 public function __construct(Session $session, EntityManagerInterface $entityManager, $parameters)
 {
     $this->parameters = $parameters;
     $this->session = $session;
     $this->cart = $this->session->get('cart');
     $this->entityManager = $entityManager;
 }
开发者ID:ernestre,项目名称:illuminati,代码行数:13,代码来源:CartProvider.php

示例7: __construct

 public function __construct(Registry $doctrine, Session $session, Logger $logger, Parameters $parameters)
 {
     $this->doctrine = $doctrine;
     $this->session = $session;
     $this->logger = $logger;
     $this->parameters = $parameters;
     $this->emFrom = $this->doctrine->getManager($this->parameters->getManagerFrom());
     $this->emTo = $this->doctrine->getManager($this->parameters->getManagerTo());
     $fromRetriever = new PgRetriever($doctrine, $this->logger, $this->parameters->getManagerFrom());
     $fromRetriever->setIndexType(PgRetriever::INDEX_TYPE_NAME);
     //$toRetriever = new PgRetriever($doctrine, $this->logger, $this->parameters->getManagerTo() );
     //$toRetriever->setIndexType(PgRetriever::INDEX_TYPE_NAME);
     $this->fromAnalyzer = new PgAnalyzer($this->logger, $fromRetriever);
     //$this->toAnalyzer = new PgAnalyzer($this->logger, $toRetriever);
     if ($this->session->has(CompareStructure::SESSION_FROM_KEY)) {
         $this->fromAnalyzer->setSchemas($this->session->get(CompareStructure::SESSION_FROM_KEY));
         $this->fromAnalyzer->initTables();
     } else {
         throw new SyncException('No source data');
     }
     /*if($this->session->has(CompareStructure::SESSION_TO_KEY)){
           $this->toAnalyzer->setSchemas($this->session->get(CompareStructure::SESSION_TO_KEY));
           $this->toAnalyzer->initTables();
       }else{
           throw new SyncException('No targeted data');
       }*/
 }
开发者ID:rombar3,项目名称:PgExplorer,代码行数:27,代码来源:SyncData.php

示例8: getCurrentSite

 public function getCurrentSite(Request $request)
 {
     $currentSite = null;
     $siteId = $request->get('site');
     if (!$siteId && $this->session->has(self::SESSION_NAME)) {
         $currentSiteId = $this->session->get(self::SESSION_NAME);
         $currentSite = $this->siteManager->find($currentSiteId);
         if (!$currentSite) {
             $sites = $this->getSites();
             if (count($sites) > 0) {
                 $currentSite = $this->getSites()[0];
             }
         }
     } else {
         foreach ($this->getSites() as $site) {
             if ($siteId && $site->getId() == $siteId) {
                 $currentSite = $site;
             } elseif (!$siteId && $site->getIsDefault()) {
                 $currentSite = $site;
             }
         }
         if (!$currentSite && count($this->sites) > 0) {
             $currentSite = $this->sites[0];
         }
     }
     if ($currentSite) {
         $this->session->set(self::SESSION_NAME, $currentSite->getId());
     }
     return $currentSite;
 }
开发者ID:symbio,项目名称:orangegate4-page-bundle,代码行数:30,代码来源:SitePool.php

示例9: loadUserByUsername

 /**
  * {@inheritdoc}
  */
 public function loadUserByUsername($username, $password = null)
 {
     // if the password is not passed in, we have arrived here from a login form, so grab it from the request
     if (null === $password) {
         $password = Request::createFromGlobals()->get('_password');
     }
     $credentials = array('email' => $username, 'password' => $password);
     $client = $this->irisEntityManager->getClient();
     // use the MAC in the session to access the cached system credentials
     $authData = $this->session->get('auth-data');
     if (!$client->hasValidCredentials($authData->get('systemKey'), $authData->get('systemSecret'))) {
         throw new BadCredentialsException('Invalid System credentials for IRIS');
     }
     // attempt to authenticate and get the Landlords key and secret
     if (false === ($oauthCredentials = $client->assume($credentials))) {
         // invalid credentials
         throw new UsernameNotFoundException('Invalid Landlord credentials for IRIS');
     }
     // create the User to return it to be stored in the session
     $user = new LandlordUser($authData->get('systemKey'), $authData->get('systemSecret'), $username, $password);
     // manually set the consumer key and secret as the username and password do not represent them
     $user->setConsumerKey($oauthCredentials['consumerKey']);
     $user->setConsumerSecret($oauthCredentials['consumerSecret']);
     return $user;
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:28,代码来源:LandlordUserProvider.php

示例10: onKernelRequest

 public function onKernelRequest(GetResponseEvent $event)
 {
     if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
         // don't do anything if it's not the master request
         return;
     }
     $token = $this->context->getToken();
     if (is_null($token)) {
         return;
     }
     $_route = $event->getRequest()->attributes->get('_route');
     if ($this->context->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
         if (!$token->getUser() instanceof PersonInterface) {
             // We don't have a PersonInterface... Nothing to do here.
             return;
         }
         if ($_route == 'lc_home' || $_route == 'fos_user_security_login') {
             $key = '_security.main.target_path';
             #where "main" is your firewall name
             //check if the referer session key has been set
             if ($this->session->has($key)) {
                 //set the url based on the link they were trying to access before being authenticated
                 $url = $this->session->get($key);
                 //remove the session key
                 $this->session->remove($key);
             } else {
                 $url = $this->router->generate('lc_dashboard');
             }
             $event->setResponse(new RedirectResponse($url));
         } else {
             $this->checkUnconfirmedEmail();
         }
     }
 }
开发者ID:hacklabr,项目名称:login-cidadao,代码行数:34,代码来源:LoggedInUserListener.php

示例11: getChoices

 /**
  *
  * @return array
  */
 public function getChoices()
 {
     if ($this->sessionManager->has('choices')) {
         return $this->sessionManager->get('choices');
     }
     return [];
 }
开发者ID:e-ReColNat,项目名称:recolnat-diff,代码行数:11,代码来源:SessionHandler.php

示例12: __construct

 public function __construct(Session $session, Connection $conn)
 {
     //Fetching equipment requests count
     $stmt = $conn->prepare("SELECT dept_name FROM staff  where user_id =:user_id;");
     $stmt->bindValue(':user_id', $session->get('user_id'));
     $stmt->execute();
     $staff_member = $stmt->fetch()['dept_name'];
     $stmt = $conn->prepare('SELECT COUNT(DISTINCT request_id) AS count FROM resource_request WHERE (resource_request.resource_id is NULL OR resource_request.resource_id IN (SELECT resource_id FROM equipment)) AND resource_request.department_name = :dept_name AND resource_request.status = 2 AND date_from >= CURDATE();');
     $stmt->bindValue(':dept_name', $staff_member);
     $stmt->execute();
     $this->equipment_requests_count = $stmt->fetch()['count'];
     //Fetching venues requests count
     $stmt = $conn->prepare('CREATE OR REPLACE VIEW admin_resource_view  as select venue.resource_id from venue INNER JOIN resource_administration on venue.resource_id = resource_administration.resource_id and resource_administration.user_id = :user_id;');
     $stmt->bindValue(':user_id', $session->get('user_id'));
     $stmt->execute();
     $stmt = $conn->prepare('SELECT COUNT(DISTINCT request_id) AS count FROM resource_request INNER JOIN view1 using(resource_id) WHERE status = 2 AND date_from >= CURDATE();');
     $stmt->execute();
     $this->venue_requests_count = $stmt->fetch()['count'];
     //Fetching vehicle requests count
     $stmt = $conn->prepare('SELECT COUNT(DISTINCT vehicle_request.request_id) AS count FROM (vehicle_request INNER JOIN vehicle ON vehicle.type = vehicle_request.requested_type) INNER JOIN vehicle_administration ON vehicle.plate_no = vehicle_administration.plate_no WHERE vehicle_administration.user_id = :user_id AND vehicle_request.status = 2 AND date >= CURDATE();');
     $stmt->bindValue(':user_id', $session->get('user_id'));
     $stmt->execute();
     $this->vehicle_requests_count = $stmt->fetch()['count'];
     //Fetching access level
     $stmt = $conn->prepare('SELECT access_level FROM login INNER JOIN user USING(user_id) WHERE user_id = :user_id AND active = true;');
     $stmt->bindValue(':user_id', $session->get('user_id'));
     $stmt->execute();
     $this->access_level = $stmt->fetch()['access_level'];
 }
开发者ID:nadundesilva,项目名称:SpacebitResourceManager,代码行数:29,代码来源:UIUtils.php

示例13: getSessionToken

 /**
  * {@inheritdoc}
  */
 protected function getSessionToken()
 {
     if (!$this->session->has($this->name)) {
         $this->session->set($this->name, sha1(uniqid(rand(), true)));
     }
     return $this->session->get($this->name);
 }
开发者ID:jacobjjc,项目名称:PageKit-framework,代码行数:10,代码来源:SessionCsrfProvider.php

示例14: __construct

 /**
  * @param Registry $doctrine
  * @param Session $session
  * @param Logger $logger
  * @param Parameters $parameters
  */
 public function __construct(Registry $doctrine, Session $session, Logger $logger, Parameters $parameters)
 {
     $this->doctrine = $doctrine;
     $this->session = $session;
     $this->logger = $logger;
     $this->parameters = $parameters;
     $fromRetriever = new PgRetriever($doctrine, $this->logger, $this->parameters->getManagerFrom());
     $fromRetriever->setIndexType(PgRetriever::INDEX_TYPE_NAME);
     $fromMassRetriever = new PgMassRetriever($doctrine, $this->logger, $this->parameters->getManagerFrom());
     $toRetriever = new PgRetriever($doctrine, $this->logger, $this->parameters->getManagerTo());
     $toRetriever->setIndexType(PgRetriever::INDEX_TYPE_NAME);
     $toMassRetriever = new PgMassRetriever($doctrine, $this->logger, $this->parameters->getManagerTo());
     $this->fromAnalyzer = new PgAnalyzer($this->logger, $fromRetriever, $fromMassRetriever);
     $this->toAnalyzer = new PgAnalyzer($this->logger, $toRetriever, $toMassRetriever);
     if ($this->session->has(SyncHandler::SESSION_FROM_KEY)) {
         $this->fromAnalyzer->setSchemas($this->session->get(SyncHandler::SESSION_FROM_KEY));
         $this->fromAnalyzer->initTables();
     } else {
         $this->fromAnalyzer->initSchemas();
         $this->fromAnalyzer->initSchemasElements();
         $this->fromAnalyzer->initCompareTableInfo();
         //$this->session->set(SyncHandler::SESSION_FROM_KEY, $this->fromAnalyzer->getSchemas());
     }
     if ($this->session->has(SyncHandler::SESSION_TO_KEY)) {
         $this->toAnalyzer->setSchemas($this->session->get(SyncHandler::SESSION_TO_KEY));
         $this->toAnalyzer->initTables();
     } else {
         $this->toAnalyzer->initSchemas();
         $this->toAnalyzer->initSchemasElements();
         $this->toAnalyzer->initCompareTableInfo();
         $this->toAnalyzer->initTables();
         //$this->session->set(SyncHandler::SESSION_TO_KEY, $this->toAnalyzer->getSchemas());
     }
 }
开发者ID:rombar3,项目名称:PgExplorer,代码行数:40,代码来源:CompareStructure.php

示例15: handleSessionValidation

 /**
  * @param \Symfony\Component\HttpFoundation\Session\Session $session
  */
 public function handleSessionValidation(SymfonySession $session)
 {
     $ip_address = new IPAddress($this->request->getClientIp());
     $request_ip = $ip_address->getIp(IPAddress::FORMAT_IP_STRING);
     $invalidate = false;
     $ip = $session->get('CLIENT_REMOTE_ADDR');
     $agent = $session->get('CLIENT_HTTP_USER_AGENT');
     $request_agent = $this->request->server->get('HTTP_USER_AGENT');
     // Validate the request IP
     if ($this->shouldCompareIP() && $ip && $ip != $request_ip) {
         if ($this->logger) {
             $this->logger->debug('Session Invalidated. Session IP "{session}" did not match provided IP "{client}".', array('session' => $ip, 'client' => $request_ip));
         }
         $invalidate = true;
     }
     // Validate the request user agent
     if ($this->shouldCompareAgent() && $agent && $agent != $request_agent) {
         if ($this->logger) {
             $this->logger->debug('Session Invalidated. Session user agent "{session}" did not match provided agent "{client}"', array('session' => $agent, 'client' => $request_agent));
         }
         $invalidate = true;
     }
     if ($invalidate) {
         $session->invalidate();
     } else {
         if (!$ip && $request_ip) {
             $session->set('CLIENT_REMOTE_ADDR', $request_ip);
         }
         if (!$agent && $request_agent) {
             $session->set('CLIENT_HTTP_USER_AGENT', $request_agent);
         }
     }
 }
开发者ID:digideskio,项目名称:concrete5,代码行数:36,代码来源:SessionValidator.php


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