2012-10-20 110 views
0

試圖在Zend Framework 2上進行管理的網站,將授權設置爲mysite/admin/login。 之後,如果授權未完成,如何拒絕訪問?Zend Framework中的會話管理2

在ZF1中,我使用了«BaseController»,但ZF2想要在Module Module中檢查會話。

class Module 
{ 
    public function onBootstrap($e) 
    { 
     $app = $e->getApplication(); 
     $sm = $app->getServiceManager(); 
     $config = $sm->get('Configuration'); 

     // DB Adapter 
     $adapter = $sm->get('Zend\Db\Adapter\Adapter'); 
     GlobalAdapterFeature::setStaticAdapter($adapter); 

     // Session 
     $sessionConfig = new SessionConfig(); 
     $sessionConfig->setOptions($config['session']); 
     $sessionManager = new SessionManager($sessionConfig, null, null); 
     Container::setDefaultManager($sessionManager); 
     $sessionManager->start(); 
    } 
} 

告訴我我是否想做?並在哪個方向看?

+0

[zend session和zend auth]可能的重複(http://stackoverflow.com/questions/9001847/zend-session-and-zend-auth) – chris

回答

0

嘗試使用Zendframe Work 2 EventManager

+0

謝謝,我會盡力的。 – SmClass

+0

我不認爲這個評論是有用的。 –