zend framework2 - can't get Container's value in Zend2 -
actually storing on value in container in index action fetching value in same action not able fetch value in action of same controller in controller...am missing something?
this code..
indexcontroller
class indexcontroller extends abstractactioncontroller { public function indexaction() { $session=new container('temp'); $session->username="bhavik"; error_log("in index controller value=$session->username"); return new viewmodel(); } public function welcomeaction() { $session = new container('temp'); error_log("in index controller welcome action value==".$session->username); $username = $session->username; return new viewmodel(); } }
this configuration in
module.php
public function initsession($config) { $sessionconfig = new sessionconfig(); $sessionconfig->setoptions($config); $sessionmanager = new sessionmanager($sessionconfig); $sessionmanager->start(); container::setdefaultmanager($sessionmanager); } public function onbootstrap(mvcevent $e) { $eventmanager = $e->getapplication()->geteventmanager(); $moduleroutelistener = new moduleroutelistener(); $moduleroutelistener->attach($eventmanager); $this->initsession(array( // 'remember_me_seconds' => 240, 'use_cookies' => true, 'cookie_lifetime' => 2592000, // 'cookie_httponly' => true, 'gc_maxlifetime' => 2592000 )); }
this , common configs , use.. able fetch value of $session->username in index action not in welcome action..
any appreciated.
Comments
Post a Comment