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


PHP SessionManager::start方法代码示例

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


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

示例1: __invoke

 /**
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @param callable|null $next
  * @return ResponseInterface
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
 {
     $this->sessionManager->start();
     Container::setDefaultManager($this->sessionManager);
     $container = new Container('initialized');
     if (isset($container->init)) {
         return $next($request, $response);
     }
     $this->sessionManager->regenerateId(true);
     $container->init = true;
     if ($next) {
         return $next($request, $response);
     }
     return $response;
 }
开发者ID:xorock,项目名称:expressive-zend-session,代码行数:21,代码来源:ZendSessionMiddleware.php

示例2: onBootstrap

 public function onBootstrap(Event $e)
 {
     $session = new SessionManager();
     if (!$session->sessionExists()) {
         $session->start();
     }
 }
开发者ID:mxmz-,项目名称:LfjOpauth,代码行数:7,代码来源:Module.php

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

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

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

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

示例8: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     /* @var $sm \Zend\ServiceManager\ServiceManager */
     $sm = $e->getApplication()->getServiceManager();
     $config = $sm->get('Config');
     // bootstrap session
     $tableGateway = new TableGateway($config['app']['session.tableName'], $sm->get('dbAdapter'));
     $saveHandler = new DbTableGateway($tableGateway, new DbTableGatewayOptions());
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions($config['session']);
     $sessionManager = new SessionManager($sessionConfig);
     $sessionManager->setSaveHandler($saveHandler);
     $sessionManager->start();
     Container::setDefaultManager($sessionManager);
     // translate
     $sm->get('translator');
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     // bootstrap locale
     //     	$headers = $app->getRequest()->getHeaders();
     //     	Locale::setDefault($config['locale']['default']);
     //     	if($headers->has('Accept-Language')) {
     //     		$locales = $headers->get('Accept-Language')->getPrioritized();
     //     		// Loop through all locales, highest priority first
     //     		foreach($locales as $locale) {
     //     			if(!!($match = Locale::lookup($config['locale']['supported'], $locale->typeString))) {
     //     				// The locale is one of our supported list
     //     				Locale::setDefault($match);
     //     				break;
     //     			}
     //     		}
     //     		if(!$match) {
     //     			// Nothing from the supported list is a match
     //     			Locale::setDefault($config['locale']['default']);
     //     		}
     //     	}
     // switch layout
     $e->getApplication()->getEventManager()->getSharedManager()->attach('Zend\\Mvc\\Controller\\AbstractActionController', 'dispatch', function ($e) {
         $controller = $e->getTarget();
         $controllerClass = get_class($controller);
         $moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\'));
         $config = $e->getApplication()->getServiceManager()->get('config');
         $routeMatch = $e->getRouteMatch();
         $actionName = strtolower($routeMatch->getParam('action', 'not-found'));
         // get the action name
         if (isset($config['module_layouts'][$moduleNamespace][$actionName])) {
             $controller->layout($config['module_layouts'][$moduleNamespace][$actionName]);
         } elseif (isset($config['module_layouts'][$moduleNamespace]['default'])) {
             $controller->layout($config['module_layouts'][$moduleNamespace]['default']);
         }
     }, 100);
 }
开发者ID:NguyenQuiDuong,项目名称:Funix,代码行数:53,代码来源:Module.php

示例9: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $app = $e->getApplication();
     $sm = $app->getServiceManager();
     $request = $app->getRequest();
     $response = $app->getResponse();
     $appConfig = $sm->get('Configuration');
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions($appConfig['session']);
     $sessionManager = new SessionManager($sessionConfig);
     $sessionManager->start();
     $responseHeaders = $response->getHeaders();
     $requestHeaders = $request->getHeaders();
     $this->checkCloudFlareHttpHeader();
     $requestUriPath = $request->getUri()->getPath();
     $requestExtension = pathinfo($requestUriPath, PATHINFO_EXTENSION);
     if (!in_array($requestExtension, ['js', 'css'])) {
         $eventManager = $app->getEventManager();
         $moduleRouteListener = new ModuleRouteListener();
         $moduleRouteListener->attach($eventManager);
         $sharedManager = $eventManager->getSharedManager();
         $sharedManager->attach('Zend\\Mvc\\Controller\\AbstractActionController', 'dispatch', function ($e) use($sm) {
             $controller = $e->getTarget();
             $controller->getEventManager()->attachAggregate($sm->get('Visitor'));
         }, 2);
         $client = new RemoteAddress();
         $queryParams = $request->getQuery();
         $setPartnerId = (isset($queryParams['gid']) and is_numeric($queryParams['gid'])) ? ['gid' => (int) $queryParams['gid'], 'url' => $request->getUri()] : FALSE;
         $setLang = (isset($queryParams['lang']) and is_string($queryParams['lang'])) ? ['lang' => $queryParams['lang'], 'url' => $request->getUri()] : FALSE;
         $setCurrency = (isset($queryParams['cur']) and is_string($queryParams['cur'])) ? ['cur' => $queryParams['cur'], 'url' => $request->getUri()] : FALSE;
         if ($requestHeaders->has('Accept-Language')) {
             $browserLang = $requestHeaders->get('Accept-Language')->getPrioritized();
         } else {
             $browserLang = FALSE;
         }
         if ($requestHeaders->has('User-Agent')) {
             $userAgent = $requestHeaders->get('User-Agent')->getFieldValue();
         } else {
             $userAgent = FALSE;
         }
         if ($requestHeaders->has('Referer')) {
             $referer = $requestHeaders->get('Referer');
         } else {
             $referer = FALSE;
         }
         $eventManager->trigger('detectVisitor', $this, array('setLang' => $setLang, 'setCurrency' => $setCurrency, 'browserLang' => $browserLang, 'userAgent' => $userAgent, 'referer' => $referer, 'request' => $request, 'clientIp' => $client->getIpAddress(), 'clientProxy' => $client->getUseProxy(), 'setPartnerId' => $setPartnerId, 'sessionManager' => $sessionManager, 'response' => $response, 'responseHeaders' => $responseHeaders, 'requestHeaders' => $requestHeaders, 'serviceLocator' => $sm));
         $eventManager->attach(\Zend\Mvc\MvcEvent::EVENT_ROUTE, array($this, 'onPreDispatch'));
     }
     $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
     GlobalAdapterFeature::setStaticAdapter($dbAdapter);
 }
开发者ID:arbi,项目名称:MyCode,代码行数:51,代码来源:Module.php

示例10: initSession

 public function initSession($config, \Zend\ServiceManager\ServiceManager $sm)
 {
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions($config);
     $sessionManager = new SessionManager($sessionConfig);
     $sessionManager->getValidatorChain()->attach('session.validate', array(new HttpUserAgent(), 'isValid'));
     $sessionManager->getValidatorChain()->attach('session.validate', array(new RemoteAddr(), 'isValid'));
     $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
     $tableGateway = new TableGateway(new TableIdentifier('sessions', 'users'), $dbAdapter);
     $saveHandler = new DbTableGateway($tableGateway, new DbTableGatewayOptions());
     $sessionManager->setSaveHandler($saveHandler);
     $sessionManager->start();
     Container::setDefaultManager($sessionManager);
 }
开发者ID:qbonaventure,项目名称:users,代码行数:14,代码来源:Module.php

示例11: __invoke

 public function __invoke()
 {
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions($this->config['options']);
     $sessionManager = new SessionManager($sessionConfig);
     if (class_exists(\Redis::class)) {
         $saveHandler = new Redis($this->config['redis']['host'], $this->config['redis']['port'], $this->config['redis']['password']);
         $sessionManager->setSaveHandler($saveHandler);
         $sessionManager->start();
     } else {
         trigger_error('Redis extension is not found. ' . \Staticus\Auth\AuthSessionMiddleware::class . ' will not work.', E_USER_NOTICE);
     }
     return $sessionManager;
 }
开发者ID:kivagant,项目名称:staticus-core,代码行数:14,代码来源:SessionManagerFactory.php

示例12: init

 public function init($sid = '')
 {
     try {
         if ($sid != '') {
             parent::setId($sid);
         }
         parent::start();
         $this->default = $this->container('Manager');
         if (!$this->default->timestamp) {
             $this->default->timestamp = time();
         }
     } catch (EMException $e) {
         throw $e;
     }
 }
开发者ID:elymatos,项目名称:expressive,代码行数:15,代码来源:MSession.php

示例13: ingresoAction

 /**
  * Metodo para validar acceso al portal
  * @return \Zend\View\Model\ViewModel
  */
 public function ingresoAction()
 {
     if ($this->getRequest()->isPost()) {
         $auth = new AuthenticationService();
         $validate = $this->getRequest()->getPost();
         $authAdapter = new AuthAdapter($this->adapter(), 'usuario', 'usuario_correo', 'usuario_password');
         $authAdapter->setIdentity($validate['correo']);
         $authAdapter->setCredential(md5($validate['password']));
         $resultado = $auth->authenticate($authAdapter);
         switch ($resultado->getCode()) {
             case Result::FAILURE_IDENTITY_NOT_FOUND:
                 $this->message = "Usuario y/o contraseña incorrectos";
                 $this->flashMessenger()->addMessage($this->message);
                 return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/login');
             case Result::FAILURE_CREDENTIAL_INVALID:
                 $this->message = "Usuario y/o contraseña incorrectos";
                 $this->flashMessenger()->addMessage($this->message);
                 return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/login');
             case Result::SUCCESS:
                 $this->flashMessenger()->clearMessages();
                 $store = $auth->getStorage();
                 $store->write($authAdapter->getResultRowObject(null, 'usuario_password'));
                 $sessionConfig = new StandardConfig();
                 $sessionConfig->setRememberMeSeconds(20)->setCookieLifetime(30)->setCookieSecure(true)->setGcMaxlifetime(60)->setGcDivisor(60);
                 $sesionMa = new SessionManager($sessionConfig);
                 $sesionMa->rememberMe(30);
                 $container = new Container('cbol');
                 $container->setExpirationSeconds(1800);
                 $sesionMa->start();
                 $container->idSession = $auth->getIdentity()->perfil_id;
                 $permisos = $this->getPermisos($auth->getIdentity()->usuario_id);
                 $container->permisosUser = $permisos;
                 $indexProfile = \Login\IndexAllProfile::listIndexAllProfiles($auth->getIdentity()->perfil_id);
                 if ($indexProfile == 'vias') {
                     $container->reportesVias = $this->getReportesViales();
                 }
                 if ($indexProfile == 'admin') {
                     $container->sugerencias = $this->getSugerenciasAction();
                 }
                 $container->setDefaultManager($sesionMa);
                 return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . "/{$indexProfile}");
             default:
                 echo 'Mensaje por defecto';
                 break;
         }
     }
 }
开发者ID:nathalysalamanca,项目名称:Observatorio,代码行数:51,代码来源:LoginController.php

示例14: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $evm = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($evm);
     /** @var ServiceManager $sm */
     $sm = $e->getApplication()->getServiceManager();
     $evm->attachAggregate($sm->get('App\\ExceptionLoggerListener'));
     $config = $e->getApplication()->getServiceManager()->get('config');
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions($config['session']);
     $sessionManager = new SessionManager($sessionConfig);
     $sessionManager->start();
     SessionContainer::setDefaultManager($sessionManager);
     $evm->attach(MvcEvent::EVENT_DISPATCH, function (MvcEvent $e) {
         $this->initEnv($e);
     }, 100);
 }
开发者ID:kstefan,项目名称:zf-skeleton,代码行数:18,代码来源:Module.php

示例15: onBootstrap

 /**
  * Run for every request to the system.
  *
  * This function does a lot. It register all kinds of event.
  * Logs critical error. Select correct layouts, just to
  * name a few points....
  *
  * @param MvcEvent $e
  */
 public function onBootstrap(MvcEvent $e)
 {
     $logger = $e->getApplication()->getServiceManager()->get('Logger');
     //CONFIG
     //	get config values from the application
     //	config files.
     $config = $e->getApplication()->getServiceManager()->get('Configuration');
     //SESSION
     //	config and start session
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions($config['session']);
     $sessionManager = new SessionManager($sessionConfig);
     $sessionManager->start();
     //SHUT DOWN
     //	register shutdown function that will log a critical message
     //
     register_shutdown_function(function () use($logger) {
         if ($e = error_get_last()) {
             $logger->critical("register_shutdown_function: " . $e['message'] . " in " . $e['file'] . ' line ' . $e['line']);
             echo "Smá vandræði";
         }
     });
     //EVENT MANAGER
     //	get event manager and attache event handlers to it. These
     //	event are something required for the MVC to work. And
     //	error events in the MVC application; ie. if something
     //	goes wrong in Dispatch or Rendering, these events will be called,
     //	they will  log a critical message
     $eventManager = $e->getApplication()->getEventManager();
     /** @var  $eventManager \Zend\EventManager\Event */
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $eventManager->attach($e->getApplication()->getServiceManager()->get('Stjornvisi\\Event\\SystemExceptionListener'));
     $eventManager->attach($e->getApplication()->getServiceManager()->get('Stjornvisi\\Event\\PersistenceLoginListener'));
     $eventManager->attach($e->getApplication()->getServiceManager()->get('Stjornvisi\\Event\\LayoutSelectListener'));
     $eventManager->getSharedManager()->attach(__NAMESPACE__, 'notify', $e->getApplication()->getServiceManager()->get('Stjornvisi\\Event\\NotifyListener'));
 }
开发者ID:bix0r,项目名称:Stjornvisi,代码行数:46,代码来源:Module.php


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