當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Session\SessionManager類代碼示例

本文整理匯總了PHP中Zend\Session\SessionManager的典型用法代碼示例。如果您正苦於以下問題:PHP SessionManager類的具體用法?PHP SessionManager怎麽用?PHP SessionManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了SessionManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: indexAction

 public function indexAction()
 {
     $form = new LoginForm();
     $authService = $this->getServiceLocator()->get('Zend\\Authentication\\AuthenticationService');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $data = $form->getData();
             $adapter = $authService->getAdapter();
             $adapter->setIdentityValue($data['email']);
             $adapter->setCredentialValue($data['password']);
             $authResult = $authService->authenticate();
             if ($authResult->isValid()) {
                 $identity = $authResult->getIdentity();
                 $authService->getStorage()->write($identity);
                 $time = 1209600;
                 // 14 days 1209600/3600 = 336 hours => 336/24 = 14 days
                 //-					if ($data['rememberme']) $authService->getStorage()->session->getManager()->rememberMe($time); // no way to get the session
                 if ($data['remember-me']) {
                     $sessionManager = new SessionManager();
                     $sessionManager->rememberMe($time);
                 }
                 return $this->redirect()->toRoute('user_dashboard');
             } else {
                 $this->flashMessenger()->addErrorMessage("Invalid login credentials provided. Try again, or sign up!");
             }
         }
     }
     $view = new ViewModel(array('form' => $form));
     return $view;
 }
開發者ID:JonathanConner,項目名稱:SocialNet,代碼行數:32,代碼來源:LoginController.php

示例2: onBootstrap

 public function onBootstrap(Event $e)
 {
     $session = new SessionManager();
     if (!$session->sessionExists()) {
         $session->start();
     }
 }
開發者ID:mxmz-,項目名稱:LfjOpauth,代碼行數:7,代碼來源:Module.php

示例3: loginAction

 public function loginAction()
 {
     $form = $this->getAuthForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $authenticationService = $this->getAuthenticationService();
             $authAdapter = $authenticationService->getAdapter();
             $authAdapter->setLogin($request->getPost('email'));
             $authAdapter->setSenha($request->getPost('senha'));
             $resultado = $authenticationService->authenticate()->isValid();
             if ($resultado) {
                 $authenticationService->getStorage()->write($authenticationService->getIdentity()['cliente']);
                 if ($request->getPost('lembrar') == 'sim') {
                     $tempo = 2592000000.0;
                     // 30 dias em milissegundos
                     $SessionManager = new SessionManager();
                     $SessionManager->rememberMe($tempo);
                 }
                 return $this->redirect()->toRoute('cliente', array('controller' => 'cliente', 'action' => 'index'));
             } else {
                 echo "Login ou senha incorreto";
             }
         }
     }
     $viewModel = new ViewModel(['form' => $form]);
     return $viewModel->setTerminal(true);
 }
開發者ID:Rafael-Fontes,項目名稱:CFP_EX,代碼行數:29,代碼來源:AuthController.php

示例4: initSession

 public function initSession($config)
 {
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions($config);
     $sessionManager = new SessionManager($sessionConfig);
     $sessionManager->start();
     Container::setDefaultManager($sessionManager);
 }
開發者ID:DCONLINE1984,項目名稱:surveyengine,代碼行數:8,代碼來源:Module.php

示例5: sessionStart

 public function sessionStart(MvcEvent $event)
 {
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions(array());
     $sessionManager = new SessionManager($sessionConfig);
     $sessionManager->start();
     Container::setDefaultManager($sessionManager);
 }
開發者ID:petresevic,項目名稱:test,代碼行數:8,代碼來源:Module.php

示例6: init

 /**
  *  @return void
  */
 private function init()
 {
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions($this->config);
     $sessionManager = new SessionManager($sessionConfig);
     $sessionManager->start();
     Container::setDefaultManager($sessionManager);
 }
開發者ID:kayo-almeida,項目名稱:cms-zend,代碼行數:11,代碼來源:Login.php

示例7: getServiceConfig

 public function getServiceConfig()
 {
     return array('factories' => array('JYLibrary\\Model\\SessionTable' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $table = new SessionTable($dbAdapter);
         return $table;
     }, 'Zend\\Session\\SessionManager' => function ($sm) {
         $config = $sm->get('config');
         if (isset($config['session'])) {
             $session = $config['session'];
             $sessionConfig = null;
             if (isset($session['config'])) {
                 $class = isset($session['config']['class']) ? $session['config']['class'] : 'Zend\\Session\\Config\\SessionConfig';
                 $options = isset($session['config']['options']) ? $session['config']['options'] : array();
                 $sessionConfig = new $class();
                 $sessionConfig->setOptions($options);
             }
             $sessionStorage = null;
             if (isset($session['storage'])) {
                 $class = $session['storage'];
                 $sessionStorage = new $class();
             }
             $sessionSaveHandler = null;
             if (isset($session['save_handler'])) {
                 // class should be fetched from service manager since it will require constructor arguments
                 $sessionSaveHandler = $sm->get($session['save_handler']);
             }
             $sessionManager = new SessionManager($sessionConfig, $sessionStorage, $sessionSaveHandler);
             if (isset($session['validator'])) {
                 $chain = $sessionManager->getValidatorChain();
                 foreach ($session['validator'] as $validator) {
                     $validator = new $validator();
                     $chain->attach('session.validate', array($validator, 'isValid'));
                 }
             }
         } else {
             $sessionManager = new SessionManager();
             /*
             $adapter = new \Zend\Db\Adapter\Adapter(array(
             	'driver' => 'Mysqli',
             	'database' => 'jymobile',
             	'username' => 'root',
             	'password' => '',
             	'hostname'=>'localhost'
             ));
             
             $tableGateway = new TableGateway('session', $adapter);
             $saveHandler = new DbTableGateway($tableGateway, new DbTableGatewayOptions());
             $manager = new SessionManager();
             $manager->setSaveHandler($saveHandler);
             
             //echo '×Ô¶¨ÒåsessionManager';
             */
         }
         Container::setDefaultManager($sessionManager);
         return $sessionManager;
     }));
 }
開發者ID:blackjackedu,項目名稱:FreeMLib,代碼行數:58,代碼來源:Module.php

示例8: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $session = new SessionManager();
     $session->start();
     $eventManager->attach('dispatch', array($this, 'secureSession'));
 }
開發者ID:RodMing,項目名稱:iERP,代碼行數:9,代碼來源:Module.php

示例9: preDispatch

 public function preDispatch(MvcEvent $event)
 {
     $sessionManager = new SessionManager();
     $existedSessionId = $this->getSessionIfFromRequest($event->getRequest());
     if ($existedSessionId) {
         $sessionManager->setId($existedSessionId);
     }
     AuthenticationManager::getInstance()->setSessionManager($sessionManager);
 }
開發者ID:qshurick,項目名稱:auth,代碼行數:9,代碼來源:Session.php

示例10: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $sess = new SessionManager();
     $sess->start();
     Container::setDefaultManager($sess);
 }
開發者ID:phiKremer,項目名稱:WebDoc,代碼行數:9,代碼來源:Module.php

示例11: __construct

 /**
  * Creates a new user session manager object.
  *
  * @param ConfigManager $configManager
  * @param UserManager $userManager
  * @param SessionManager $sessionManager;
  */
 public function __construct(ConfigManager $configManager, UserManager $userManager, SessionManager $sessionManager)
 {
     $this->configManager = $configManager;
     $this->userManager = $userManager;
     $this->sessionManager = $sessionManager;
     /* Prepare session validators */
     $sessionManager->getValidatorChain()->attach('session.validate', array(new HttpUserAgent(), 'isValid'));
     $sessionManager->getValidatorChain()->attach('session.validate', array(new RemoteAddr(), 'isValid'));
 }
開發者ID:Mendim,項目名稱:ep3-bs,代碼行數:16,代碼來源:UserSessionManager.php

示例12: configure

 public function configure($object, array $options = [])
 {
     $manager = new Session\SessionManager();
     $manager->setStorage(new Session\Storage\ArrayStorage());
     $manager->setSaveHandler(new Session\SaveHandler\Cache(new CacheStorageAdapterMemory()));
     $manager->setConfig(new Session\Config\StandardConfig());
     $session = new Session\Container('Default', $manager);
     $object->getServiceLocator()->set('Zend\\Session\\Container', $session);
 }
開發者ID:necromant2005,項目名稱:tt-test,代碼行數:9,代碼來源:ZendSessionContainer.php

示例13: getServiceConfig

 public function getServiceConfig()
 {
     return array('factories' => array('Zend\\Session\\SessionManager' => function ($sm) {
         $db = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $saveHandler = new SaveHandler();
         $saveHandler->setDb($db);
         $manager = new SessionManager();
         $manager->setSaveHandler($saveHandler);
         return $manager;
     }));
 }
開發者ID:zealproject,項目名稱:zeal-session,代碼行數:11,代碼來源:Module.php

示例14: getSessionManager

 public function getSessionManager()
 {
     $sessionManager = new ZendSessionManager($this->getConfigObject(), $this->getStorageObject(), $this->getSessionSaveHandler());
     $chain = $sessionManager->getValidatorChain();
     foreach ($this->getSessionOptions()->getValidators() as $validatorName) {
         $validator = $this->validatorPluginManager->get($validatorName);
         $chain->attach('session.validate', array($validator, 'isValid'));
     }
     SessionContainer::setDefaultManager($sessionManager);
     return $sessionManager;
 }
開發者ID:pnagaraju25,項目名稱:HtSession,代碼行數:11,代碼來源:SessionManagerProvider.php

示例15: getServiceConfig

 /**
     COPY DARI SIMBRA :D
     **/
 public function getServiceConfig()
 {
     return array('factories' => array('Fauth\\Model\\User' => function ($sm) {
         $adapter = $sm->get('TNDE\\DbAdapter');
         $table = new UserDbTable($adapter);
         return $table;
     }, 'Zend\\Session\\SessionManager' => function ($sm) {
         $config = $sm->get('config');
         if (isset($config['session'])) {
             $session = $config['session'];
             $sessionConfig = null;
             if (isset($session['config'])) {
                 $class = isset($session['config']['class']) ? $session['config']['class'] : 'Zend\\Session\\Config\\SessionConfig';
                 $options = isset($session['config']['options']) ? $session['config']['options'] : array();
                 $sessionConfig = new $class();
                 $sessionConfig->setOptions($options);
             }
             $sessionStorage = null;
             if (isset($session['storage'])) {
                 $class = $session['storage'];
                 $sessionStorage = new $class();
             }
             $sessionSaveHandler = null;
             if (isset($session['save_handler'])) {
                 // class should be fetched from service manager since it will require constructor arguments
                 $sessionSaveHandler = $sm->get($session['save_handler']);
             }
             $sessionManager = new SessionManager($sessionConfig, $sessionStorage, $sessionSaveHandler);
             if (isset($session['validator'])) {
                 $chain = $sessionManager->getValidatorChain();
                 foreach ($session['validator'] as $validator) {
                     $validator = new $validator();
                     $chain->attach('session.validate', array($validator, 'isValid'));
                 }
             }
         } else {
             $sessionManager = new SessionManager();
         }
         Container::setDefaultManager($sessionManager);
         return $sessionManager;
     }, 'Fauth\\sessionContainer' => function ($sm) {
         $container = new Container('container');
         if (!isset($container->init)) {
             $session = $sm->get('Zend\\Session\\SessionManager');
             $session->regenerateId(true);
             $container->init = 1;
         }
         return $container;
     }, 'Fauth\\authService' => function ($sm) {
         $container = $sm->get('Fauth\\sessionContainer');
         $authService = new AuthService($container);
         return $authService;
     }));
 }
開發者ID:vatoer,項目名稱:EOfficeZf2,代碼行數:57,代碼來源:Module.php


注:本文中的Zend\Session\SessionManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。