getIdentity in zf1 app when user is authenticated in zf3

264 views Asked by At

I am migrating our applications from zf1 to zf3. I am authenticating the user in ZF3 and when I goto the ZF1 apps I am getting the following error.

Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'session has already been started by session.auto-start or session_start()' in /usr/local/zendsvr6/var/libraries/Zend_Framework_1/1.12.18/library/Zend/Session.php:464 Stack trace:

#0 /usr/local/zendsvr6/var/libraries/Zend_Framework_1/1.12.18/library/Zend/Session/Namespace.php(143): Zend_Session::start(true)

#1 /usr/local/zendsvr6/var/libraries/Zend_Framework_1/1.12.18/library/Zend/Auth/Storage/Session.php(86): Zend_Session_Namespace->__construct('Zend_Auth')

#2 /usr/local/zendsvr6/var/libraries/Zend_Framework_1/1.12.18/library/Zend/Auth.php(91): Zend_Auth_Storage_Session->__construct()

#3 /usr/local/zendsvr6/var/libraries/Zend_Framework_1/1.12.18/library/Zend/Auth.php(151): Zend_Auth->getStorage()

#4 /www/zendsvr6/htdocs/accessavx/library/Custom/Controller/Plugin/Auth.php(38): Zend_Auth->getIdentity()

#5 /usr/local/zendsvr6/var/libraries/Zend_Framework_1/1.12.18/library/Zend/Controller/Plugin/Broker.php(309): Custom_Controller_Plugin_Auth->preDispatch(O in /usr/local/zendsvr6/var/libraries/Zend_Framework_1/1.12.18/library/Zend/Controller/Plugin/Broker.php on line 312

If I authenticate the user in ZF1 and goto the ZF3 apps this works fine. Is it possible to authenticate the user in ZF3 and use the same session to get the identity in zend framework 1?

1

There are 1 answers

0
Rafael Armenio On

There is no right or wrong way to do this.

You can try to recover by the default container name "Zend_Auth"

I recommend you dump into your $ _SESSION using print_r or var_dump

To enable direct access to the value you need within $ _SESSION if you can not otherwise

See an example of it in $ _SESSION:

Array
(
    [Zend_Auth] => Zend\Stdlib\ArrayObject Object
        (
            [storage:protected] => Array
                (
                    [storage] => stdClass Object
                        (
                            [id] => 1
                        )

                )

            [flag:protected] => 2
            [iteratorClass:protected] => ArrayIterator
            [protectedProperties:protected] => Array
                (
                    [0] => storage
                    [1] => flag
                    [2] => iteratorClass
                    [3] => protectedProperties
                )
        )
)