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


PHP Session::getId方法代码示例

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


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

示例1: getSessionId

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

示例2: testImplicitGrant

 public function testImplicitGrant()
 {
     // Start session manually.
     $session = new Session(new MockFileSessionStorage());
     $session->start();
     // Query authorization endpoint with response_type = token.
     $parameters = array('response_type' => 'token', 'client_id' => 'http://democlient1.com/', 'redirect_uri' => 'http://democlient1.com/redirect_uri', 'scope' => 'demoscope1', 'state' => $session->getId());
     $server = array('PHP_AUTH_USER' => 'demousername1', 'PHP_AUTH_PW' => 'demopassword1');
     $client = $this->createClient();
     $crawler = $client->request('GET', '/api/oauth2/authorize', $parameters, array(), $server);
     $this->assertTrue($client->getResponse()->isRedirect());
     // Check basic auth response that can simply compare.
     $authResponse = Request::create($client->getResponse()->headers->get('Location'), 'GET');
     $this->assertEquals('http://democlient1.com/redirect_uri', $authResponse->getSchemeAndHttpHost() . $authResponse->getBaseUrl() . $authResponse->getPathInfo());
     // Check basic token response that can simply compare.
     $tokenResponse = $authResponse->query->all();
     $this->assertEquals('bearer', $tokenResponse['token_type']);
     $this->assertEquals('demoscope1', $tokenResponse['scope']);
     $this->assertEquals($session->getId(), $tokenResponse['state']);
     // Query debug endpoint with access_token.
     $parameters = array();
     $server = array('HTTP_Authorization' => implode(' ', array('Bearer', $tokenResponse['access_token'])));
     $client = $this->createClient();
     $crawler = $client->request('GET', '/api/oauth2/debug', $parameters, array(), $server);
     $debugResponse = json_decode($client->getResponse()->getContent(), true);
     $this->assertEquals('demousername1', $debugResponse['username']);
 }
开发者ID:rakesh-mohanta,项目名称:oauth2-symfony-bundle,代码行数:27,代码来源:OAuth2Test.php

示例3: createCustomerFromSession

 private function createCustomerFromSession()
 {
     $customer = new Customer();
     $customer->setSessionId($this->session->getId());
     $this->entityManager->persist($customer);
     $this->entityManager->flush();
     return $customer;
 }
开发者ID:bamper,项目名称:symfony2-webstore,代码行数:8,代码来源:CustomerModel.php

示例4: getMediacenterUserToken

 public function getMediacenterUserToken(User $user, Mediacenter $mediacenter)
 {
     $hasInwicastToken = $this->session->get("has_inwicast_token");
     $token = $this->session->getId();
     if (!$hasInwicastToken) {
         $this->mediacenterUserRepository->createInwicastUserIfNotExists($user, $token, $mediacenter);
         $this->session->set("has_inwicast_token", true);
     }
     return $token;
 }
开发者ID:inwicast,项目名称:claroline-plugin-bundle,代码行数:10,代码来源:MediacenterUserManager.php

示例5: 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

示例6: findQueueItemsInSession

 /**
  * Find all objects having the same session as the current user.
  * @return QueueItem[]|null
  */
 public function findQueueItemsInSession()
 {
     $session = new Session();
     $sessionId = $session->getId();
     $qb = parent::createQueryBuilder('e');
     $qb->where('e.sessionId = :sessionId')->andWhere('e.isDeleted = 0')->setParameter('sessionId', $sessionId);
     return $qb->getQuery()->getResult();
 }
开发者ID:binaryfr3ak,项目名称:sfitixi,代码行数:12,代码来源:QueueItemRepositoryDoctrine.php

示例7: testNothingIsPersisted

 public function testNothingIsPersisted()
 {
     session_id('nullsessionstorage');
     $storage = $this->getStorage();
     $session = new Session($storage);
     $session->start();
     $this->assertEquals('nullsessionstorage', $session->getId());
     $this->assertNull($session->get('something'));
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:9,代码来源:NullSessionHandlerTest.php

示例8: registerQueueItem

 /**
  * @param $sessionTag
  * @param $sessionValue
  * @return QueueItem
  */
 public static function registerQueueItem($sessionTag, $sessionValue)
 {
     $session = new Session();
     $QueueItem = new QueueItem();
     $QueueItem->setSessionId($session->getId());
     $QueueItem->setSessionTag($sessionTag);
     $QueueItem->setSessionValue($sessionValue);
     return $QueueItem;
 }
开发者ID:binaryfr3ak,项目名称:sfitixi,代码行数:14,代码来源:QueueItem.php

示例9: iAmAnLoggedInAs

 /**
  * @Given I am logged in as :username
  */
 public function iAmAnLoggedInAs($username)
 {
     $session = new Session();
     $client = $this->getSession()->getDriver()->getClient();
     $client->getCookieJar()->set(new Cookie($session->getName(), $session->getId()));
     $session = $this->getContainer()->get('session');
     $user = $this->getKernel()->getContainer()->get('oauth2_server.test_bundle.end_user_manager')->getEndUserByUsername($username);
     if (null === $user) {
         throw new \Exception('Unknown user');
     }
     $token = new UsernamePasswordToken($user, 'secret', 'main', $user->getRoles());
     $session->set('_security_main', serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $client->getCookieJar()->set($cookie);
 }
开发者ID:gitter-badger,项目名称:OAuth2ServerBundle,代码行数:19,代码来源:FeatureContext.php

示例10: loginAction

 public function loginAction(Request $request)
 {
     $this->getLogger()->debug("Login request.");
     $username = $request->request->get('username');
     $password = $request->request->get('password');
     $systemDBManager = $this->get('doctrine')->getManager('system');
     $user = $systemDBManager->getRepository('AmburgerBundle:User')->checkUser($username, $password);
     if (is_numeric($user)) {
         switch ($user) {
             // username
             case -1:
                 return $this->render('AmburgerBundle:DataCorrection:login.html.twig', array('show_username_notice' => true, 'show_password_notice' => false, 'logged_in' => false));
                 // password
             // password
             case -2:
                 return $this->render('AmburgerBundle:DataCorrection:login.html.twig', array('show_password_notice' => true, 'show_username_notice' => false, 'logged_in' => false));
             default:
                 return $this->render('AmburgerBundle:DataCorrection:login.html.twig');
         }
     } else {
         //set logged in
         //set user session
         $session = $this->getRequest()->getSession();
         // Get started session
         if (!$session instanceof Session) {
             $session = new Session();
             // if there is no session, start it
             $session->start();
         }
         $value = $session->getId();
         // get session id
         $session->set('name', $username);
         $session->set('userid', $user->getId());
         $this->getLogger()->debug("Successfully logged in user: " . $username);
         if ($user->getAdmin()) {
             return $this->redirect($this->generateUrl('admin_overview'));
         } else {
             return $this->redirect($this->generateUrl('correction'));
         }
     }
 }
开发者ID:JhnMhf,项目名称:SimpleProject,代码行数:41,代码来源:LoginController.php

示例11: inject

 /**
  * Inject values into the context
  *
  * The provider is expected to use the ->set() interface on the context object to
  * provide information.
  *
  * @param ContextInterface $context
  * @return mixed
  */
 public function inject(ContextInterface $context)
 {
     $context->set('session_id', sha1($this->session->getId() . __CLASS__));
 }
开发者ID:scalopus,项目名称:VendPheatBundle,代码行数:13,代码来源:SessionProvider.php

示例12: getSessionId

 /**
  * {@inheritdoc}
  */
 protected function getSessionId()
 {
     $this->session->start();
     return $this->session->getId();
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:8,代码来源:SessionCsrfProvider.php

示例13: checkSession

 /**
  * Função para validar a sessão
  *
  * @param Session $session
  * @return bool
  */
 public function checkSession(Session $session)
 {
     $logger = $this->get('logger');
     $session->getMetadataBag()->getCreated();
     $session->getMetadataBag()->getLastUsed();
     if (time() - $session->getMetadataBag()->getLastUsed() > $this->maxIdleTime) {
         $session->invalidate();
         $logger->error("Sessão inválida:\n" . $session->getId());
         //throw new SessionExpired(); // direciona para a página de sessão expirada
         return false;
     } else {
         return true;
     }
 }
开发者ID:mistercomputer,项目名称:cacic,代码行数:20,代码来源:NeoController.php

示例14: getId

 /**
  * Extends Symfony's built in class to ensure that the session has already
  * started when we try and get the ID.
  *
  * @return string The session ID
  */
 public function getId()
 {
     parent::start();
     return parent::getId();
 }
开发者ID:mothership-ec,项目名称:cog,代码行数:11,代码来源:Session.php

示例15: searchByTextAction


//.........这里部分代码省略.........
                 $record->setTitle($item->ItemAttributes->Title);
                 $logger->info('Title: ' . $record->getTitle());
                 // label
                 if (property_exists($item->ItemAttributes, 'Brand')) {
                     $record->setRecordLabel($item->ItemAttributes->Brand);
                 } else {
                     if (property_exists($item->ItemAttributes, 'Label')) {
                         $record->setRecordLabel($item->ItemAttributes->Label);
                     } else {
                         //
                     }
                 }
                 $logger->info('Label: ' . $record->getRecordLabel());
                 // Year
                 if (property_exists($item->ItemAttributes, 'ReleaseDate')) {
                     $record->setYear(substr($item->ItemAttributes->ReleaseDate, 0, 4));
                     $logger->info('Label: ' . $record->getYear());
                 } else {
                     $logger->info('\'ReleaseDate\' not available, so dunno how to get the year...');
                 }
                 // Media count
                 if (property_exists($item->ItemAttributes, 'NumberOfItems')) {
                     $record->setMediaCount($item->ItemAttributes->NumberOfItems);
                     $logger->info('Media count: ' . $record->getMediaCount());
                 } else {
                     if (property_exists($item->ItemAttributes, 'NumberOfDiscs')) {
                         $record->setMediaCount($item->ItemAttributes->NumberOfDiscs);
                         $logger->info('Media count: ' . $record->getMediaCount());
                     } else {
                         //$logger->info(print_r($item->ItemAttributes, true));
                         $logger->info('Number of media not available. Now what?! Tentatively I guess the value \'1\'.');
                         $record->setMediaCount('1');
                         $item->ItemAttributes->NumberOfItems = '1';
                     }
                 }
                 // Media type
                 $record->setMediaType($item->ItemAttributes->Binding);
                 $logger->info('Media type: ' . $record->getMediaType());
                 // Cover image (it may be unavailable)
                 if (property_exists($item, 'LargeImage')) {
                     $record->setCoverImageUrl($item->LargeImage->URL);
                     $logger->info('Cover image URL: ' . $record->getCoverImageUrl());
                 }
                 // each media item has a track list
                 $trackLists = array();
                 if (property_exists($item, 'Tracks')) {
                     // Tracks info is not for granted...
                     // When number of media/items is greater than 1, but
                     // the tracks list is just one
                     // (it happened at least once with B000B66OVW, see EX03 below)
                     // then ->Tracks->Disc is not an array at it should be
                     // when more than one media are actually present
                     $oneListOnly = 0;
                     if (!is_array($item->Tracks->Disc)) {
                         $logger->info('The web service reported ' . $record->getMediaCount() . ' media, but all tracks are in just one list.');
                         $oneListOnly = 1;
                     }
                     if ($record->getMediaCount() < 2 || $oneListOnly) {
                         // one item only, one list
                         if (property_exists($item->Tracks, 'Disc')) {
                             $totalTracks = sizeof($item->Tracks->Disc->Track);
                             for ($i = 0; $i < $totalTracks; $i++) {
                                 $tracksLists[0][] = $item->Tracks->Disc->Track[$i]->_;
                             }
                         } else {
                             $logger->info('Couldn\'t find "Disc"...   ' . print_r($item->Tracks, true));
                         }
                     } else {
                         for ($j = 0; $j < $record->getMediaCount(); $j++) {
                             $totalTracks = sizeof($item->Tracks->Disc[$j]->Track);
                             for ($i = 0; $i < $totalTracks; $i++) {
                                 $tracksLists[$j][] = $item->Tracks->Disc[$j]->Track[$i]->_;
                             }
                         }
                     }
                     $record->setTracksLists($tracksLists);
                 } else {
                     // Tracks info is not available (no property "Tracks" in the object)
                     $logger->info('Tracks info is not available');
                 }
                 // Appending the record to the list of possible records
                 $records[] = $record;
             }
         }
         // TODO:
         // saving the array of results in session
         $session = new Session();
         //$session->start();
         $session->set('results', $records);
         $logger->info('Session ID: ' . $session->getId());
         // Returning the list of the results
         // TODO:
         // handling in the template the id of each record, so that in can be passed
         // afterwards for insertion and recovered from session without re-fetching
         // its data
         return $this->render('AppBundle:Record:results.html.twig', array('records' => $records));
     }
     // The form has not been submitted, displaying the form
     return $this->render('AppBundle:Record:searchByText.html.twig', array('form' => $form->createView()));
 }
开发者ID:AppLEaDaY,项目名称:recordsLibrary,代码行数:101,代码来源:RecordController.php


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