Jump to content

[SOLVED] Zend session question


ballhogjoni

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.