You book may be a little old.  As of CakePHP 1.3, the Session
Component is not included for your automatically.  To solve your
problem add the Session Component:

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

Please check out the migration guide for further information:
http://book.cakephp.org/view/1561/Migrating-from-CakePHP-1-2-to-1-3

-tehtreag

On Jun 30, 3:59 pm, n4thancake <hellbr...@gmail.com> wrote:
> 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 inhttp://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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to