ballhogjoni Posted November 9, 2008 Share Posted November 9, 2008 Why is this code not working? <?php Zend_Loader::loadClass('Zend_Session'); Zend_Session::start(); class AdminController extends Zend_Controller_Action{ function indexAction(){ $authNamespace = new Zend_Session_Namespace('Zend_Auth'); $authNamespace->user = $_POST['username']; } function welcomeAction(){ echo $authNamespace->user; } } ?> basically I am starting the session with Zend_Session::start(); and then getting a new instance of Zend_Session_Namespace then setting the posted username to $authNamespace->user Second function echos the $authNamespace->user. If I understand Zend Framework correctly $authNamespace->user is the session namespace, and therefore I should be able to echo $_POST['username'] in the second function. I am getting the following notices: Notice: Undefined variable: authNamespace in C:\xampp\htdocs\incentive_application\controllers\AdminController.php on line 25 Notice: Trying to get property of non-object in C:\xampp\htdocs\incentive_application\controllers\AdminController.php on line 25 It seems that the session is not global? is this correct? Link to comment https://forums.phpfreaks.com/topic/131984-solved-zend-session-question/ Share on other sites More sharing options...
ballhogjoni Posted November 9, 2008 Author Share Posted November 9, 2008 figured it out, you have to call the Zend_Session_Namespace again like: $authNamespace = new Zend_Session_Namespace('Zend_Auth'); Link to comment https://forums.phpfreaks.com/topic/131984-solved-zend-session-question/#findComment-685817 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.