Php 使用Zend\Authenticate在ZF2之外对子域进行身份验证

Php 使用Zend\Authenticate在ZF2之外对子域进行身份验证,php,zend-framework,Php,Zend Framework,我正在尝试一项看似简单的任务,即在使用Zend\Authentication的应用程序中设置会话cookie域。当我使用Zend\Authentication\Storage\Session进行存储时,我试图找出如何为会话设置cookie\u域,因为我希望跨多个子域使用相同的会话变量。这不是ZF2应用程序,我只是将Zend\Authentication用作一个单独的组件 这是我的密码: $authService = new \Zend\Authentication\AuthenticationS

我正在尝试一项看似简单的任务,即在使用Zend\Authentication的应用程序中设置会话cookie域。当我使用Zend\Authentication\Storage\Session进行存储时,我试图找出如何为会话设置cookie\u域,因为我希望跨多个子域使用相同的会话变量。这不是ZF2应用程序,我只是将Zend\Authentication用作一个单独的组件

这是我的密码:

$authService = new \Zend\Authentication\AuthenticationService();
$config = new \Zend\Session\Config\StandardConfig();
$config->setOptions(array(
    'cookie_domain' => '.jt.martyndev',
));
$manager = new \Zend\Session\SessionManager($config);
$storage = new \Zend\Authentication\Storage\Session('jt_sso', null, $manager);
$authService->setStorage($storage);
首先,我得到了这个错误:

Fatal error: Class 'Zend\Validator\Hostname' not found in /var/www/jt_sso/vendor/zendframework/zend-session/src/Config/StandardConfig.php on line 473
似乎很奇怪,我必须安装Zend\Validator,但我还是尝试了,错误消失了。但是身份验证不再起作用了,我只能想象我被错误配置了。我需要添加什么来设置我的cookie域。在尝试执行此操作之前,以下是我的原始代码:

$authService = new \Zend\Authentication\AuthenticationService();
$storage = new \Zend\Authentication\Storage\Session('jt_sso', null, $manager);
$authService->setStorage($storage);
理想情况下,我只想以最简单的正确方式设置此配置,但找不到任何与身份验证相关的内容(似乎setStorage只接受Zend\authentication\Storage\Session的实例)。非常感谢您的帮助,谢谢