簡體   English   中英

zend框架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

身份提供者。 然后在config中:配置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 ,然后我編輯了到期時間的值。 希望能幫助到你 !

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM