相关疑难解决方法(0)

Zend\Session\Container 会话验证失败异常 -- Object(Closure) ZF2

我正在尝试在 ZF2 应用程序中使用身份验证和会话。到目前为止,我有以下代码:

在我的 Module.php 中:

// (...) rest of code

public function getServiceConfig()
    {
        return array(
                'factories' => array(
                        // (...) Other factories

                        // Authentication Service
                        'AuthService' => function($sm) {
                            $dbAdapter           = $sm->get('Zend\Db\Adapter\Adapter');
                            $dbTableAuthAdapter  = new DbTable($dbAdapter,
                                'sec_user','login','password');

                            $authService = new AuthenticationService();
                            $authService->setAdapter($dbTableAuthAdapter);

                            return $authService;
                        },
                ),
        );
    }

// (...) rest of code
Run Code Online (Sandbox Code Playgroud)

然后在我的控制器登录操作中,我有:

use Zend\Session\Container;

// (...) rest of code

    public function loginAction()
    {
       $this->getAuthService()->getAdapter()
                  ->setIdentity('testlogin')
                  ->setCredential('testpass');

        $auth_result = $this->getAuthService()->getAdapter()->authenticate();

        if ($auth_result->isValid()) {
            $session = new Container(); …
Run Code Online (Sandbox Code Playgroud)

php session zend-framework2

4
推荐指数
1
解决办法
3619
查看次数

标签 统计

php ×1

session ×1

zend-framework2 ×1