zend framework 2:设置会话验证超时
zend framework 2 : Set session authentification timeout
我遇到身份验证会话没有过期的问题,这是我的身份验证代码:
$adapter = $this->getServiceLocator()->get('doctrine.authenticationadapter.orm_default');
$adapter->setOptions(array(
'objectManager' => $this->getEntityManager(),
'identityClass' => 'Application\Entity\User',
'identityProperty' => 'email',
'credentialProperty' => 'password'));
$adapter->setIdentityValue($mail);
$adapter->setCredentialValue($password);
$authService = new AuthenticationService();
$result = $authService->authenticate($adapter);
if ($result->isValid())
{
$identity = $result->getIdentity();
$authService->getStorage()->write($identity);
echo "valide";
}
else
echo "invalide";
谢谢。
你应该看到 https://github.com/bjyoungblood/BjyAuthorize
对于身份提供者。
然后在配置中:配置 role_providers.
这是我解决问题的方法:
if ($result->isValid())
{
$session = new Container('Zend_Auth');
$session->setExpirationSeconds(1800);
$identity = $result->getIdentity();
$authService->getStorage()->write($identity);
echo "valide";
}
else
echo "invalide";
我得到对象会话 Zend_Auth
,然后我编辑了过期时间的值。
希望对您有所帮助!
我遇到身份验证会话没有过期的问题,这是我的身份验证代码:
$adapter = $this->getServiceLocator()->get('doctrine.authenticationadapter.orm_default');
$adapter->setOptions(array(
'objectManager' => $this->getEntityManager(),
'identityClass' => 'Application\Entity\User',
'identityProperty' => 'email',
'credentialProperty' => 'password'));
$adapter->setIdentityValue($mail);
$adapter->setCredentialValue($password);
$authService = new AuthenticationService();
$result = $authService->authenticate($adapter);
if ($result->isValid())
{
$identity = $result->getIdentity();
$authService->getStorage()->write($identity);
echo "valide";
}
else
echo "invalide";
谢谢。
你应该看到 https://github.com/bjyoungblood/BjyAuthorize
对于身份提供者。 然后在配置中:配置 role_providers.
这是我解决问题的方法:
if ($result->isValid())
{
$session = new Container('Zend_Auth');
$session->setExpirationSeconds(1800);
$identity = $result->getIdentity();
$authService->getStorage()->write($identity);
echo "valide";
}
else
echo "invalide";
我得到对象会话 Zend_Auth
,然后我编辑了过期时间的值。
希望对您有所帮助!