So far I found the following solution. In my Module.php I do listen to the
"route" and the "finish" event. In case that the route event matches
controller zfcuser and action login I do destroy the session. Similar if the
finish event matches controller zfcuser/logout I do destroy the session.
Would love if there is a better solution. Here is my code in Module.php

    public function onBootstrap(\Zend\Mvc\MvcEvent $e) {

                $app = $e->getParam('application');
                $app->getEventManager()->attach('route', array($this, 
'onRoute'));
                $app->getEventManager()->attach('finish', array($this, 
'onFinish'));

    }

        public function onRoute(\Zend\Mvc\MvcEvent $e){
        $app        = $e->getTarget();
        $match      = $app->getMvcEvent()->getRouteMatch();
        $controller = $match->getParam('controller');
        $action     = $match->getParam('action');

                if($controller == 'zfcuser' AND ($action == 'login')){
                        $session = new \Zend\Session\Container('***');
                        $session->getManager()->destroy();
                }

        }

        public function onFinish(\Zend\Mvc\MvcEvent $e){
        $app        = $e->getTarget();
        $match      = $app->getMvcEvent()->getRouteMatch();
        $controller = $match->getParam('controller');
        $action     = $match->getParam('action');

                if($controller == 'zfcuser' AND ($action == 'logout')){
                        $session = new \Zend\Session\Container('***');
                        $session->getManager()->destroy();
                }

        }






--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-ZfcUser-Clear-Sessions-before-login-tp4657794p4657798.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to