<?php

class AppController extends Controller
{
        var $helpers = array('html', 'time');
        var $components = array('Session');

        function __construct() {
                parent::__construct();

                if($this->checkSession())
                        $this->layout = 'default';
                else
                        $this->layout = 'login';
        }

        function checkSession() {
                // If the session info hasn't been set...
                if (!$this->Session->check('User')) {
                        // Force the user to login
                        $this->redirect('/users/login');
                        exit();
                }
        }
}
?>

BTW, I'm just starting to learn cake, so sorry if some questions seem
silly.

On Oct 24, 2:01 pm, Matt Kosoy <[EMAIL PROTECTED]> wrote:
> Post the code from your app controller  so we can take a look.
>
> -m
>
> On Oct 24, 2:37 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > I'm using cake 1.1.17, and am following the Simple User Authentication
> > example from the manual (http://manual.cakephp.org/appendix/
> > simple_user_auth), and I get the following error when I write the
> > checkSession function in the app_controller.php file:
>
> > Notice: Undefined property: PagesController::$Session in /var/www/
> > cakestuff/clientes/app/app_controller.php on line 19
>
> > Fatal error: Call to a member function check() on a non-object in /var/
> > www/cakestuff/clientes/app/app_controller.php on line 19
>
> > Anyone know what I'm doing wrong?? I've google and asked on IRC, but
> > nothing.
>
> > Thanks
> > dave


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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