本文整理汇总了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;
}
示例2: onBootstrap
public function onBootstrap(Event $e)
{
$session = new SessionManager();
if (!$session->sessionExists()) {
$session->start();
}
}
示例3: sessionStart
public function sessionStart(MvcEvent $event)
{
$sessionConfig = new SessionConfig();
$sessionConfig->setOptions(array());
$sessionManager = new SessionManager($sessionConfig);
$sessionManager->start();
Container::setDefaultManager($sessionManager);
}
示例4: initSession
public function initSession($config)
{
$sessionConfig = new SessionConfig();
$sessionConfig->setOptions($config);
$sessionManager = new SessionManager($sessionConfig);
$sessionManager->start();
Container::setDefaultManager($sessionManager);
}
示例5: init
/**
* @return void
*/
private function init()
{
$sessionConfig = new SessionConfig();
$sessionConfig->setOptions($this->config);
$sessionManager = new SessionManager($sessionConfig);
$sessionManager->start();
Container::setDefaultManager($sessionManager);
}
示例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'));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
}
}
示例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);
}
示例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'));
}