Hi to all, I'm newer to CakePHP and i'm reading this book 'packt
publishing cakephp application development'.
I'm running into a problem where my controllers don't seem to be
inheriting from my AppController or someone else.
This is my code

app_controller.php
<?php
class AppController extends Controller {

        var $helpers = array('Session', 'Form');
        var $components = array('Auth', 'Cookie');

        function beforeFilter(){
                $this->Auth->loginRedirect = array('controller' => 'questions',
'action' => 'home');
                $this->Auth->logoutRedirect  = array('controller' => 
'questions',
'action' => 'home');
                $this->Auth->allow('signup', 'confirm', 'home', 'show');
                $this->Auth->authorize = 'controller';
                $this->Auth->userScope = array('User.confirmed' => '1');
                $this->set('loggedIn', $this->Auth->user('id'));

                $this->Auth->autoRedirect = false;
                $this->Cookie->name = 'QuickWall';

                if(!$this->Auth->user('id')) {
                        $cookie = $this->Cookie->read('User');
                        if($cookie) {
                                $this->Auth->login($cookie);
                        }
                }

        }

        function isAuthorized() {
                return true;
        }

}
?>

users_controller.php
......
                if ($this->Email->send()) {
                        $this->Session->setFlash('Confirmation mail sent. Please
check your inbox');
                        $this->redirect(array('controller' => 'questions',
'action'=>'home'));
                        } else {
                        $this->User->del($this->User->getLastInsertID());
                                $this->Session->setFlash('There was a problem 
sending the
confirmation mail. Please try again');
                        }
                        } else {
                                $this->Session->setFlash('There was an error 
signing up. Please,
try again.');
                                $this->data = null;
                        }
                }
        }


questions_controller.php
<?php
class QuestionsController extends AppController {

        var $name = 'Questions';

        function home() {

                if (!empty($this->data) && $this->Auth->user('id')) {
                        $this->data['Question']['user_id'] = 
$this->Auth->user('id');
                        $this->Question->create();
                        if ($this->Question->save($this->data)) {
                                $this->Session->setFlash('Your Question has 
been added');
                                $this->redirect(array('action'=>'home'), null, 
true);
                        } else {
                                $this->Session->setFlash('The Question could 
not be saved. Please,
try again.');
                        }
                }

                $this->Question->recursive = 1;
                $this->set('questions', $this->Question->find('all'));
        }


When I try to sign up or to post a question I received this error

Notice (8): Undefined property: QuestionsController::$Session [APP/
controllers/questions_controller.php, line 12]
Fatal error: Call to a member function setFlash() on a non-object in /
web/htdocs/www.endlesslab.org/home/quickwall/app/controllers/
questions_controller.php on line 12


as you can see in http://www.endlesslab.org/quickwall/

Someone can help me please?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to