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