当前位置: 首页>>代码示例>>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;未经允许,请勿转载。