I have a login controller that handles session check and login
function and other controllers that request session check to the login
controller.

Here is my problem, in cake 1.1 it's just fine, but when i switch to
cake 1.2 i get this error message :

Notice (8): Undefined variable: _SESSION [CORE\cake\libs\session.php,
line 195]

Code | Context

$name   =       "admin_id"
$var    =       "admin_id"

          return false;
        }
        $result = Set::extract($_SESSION, $var);

CakeSession::check() - CORE\cake\libs\session.php, line 195
SessionComponent::check() - CORE\cake\libs\controller\components
\session.php, line 197
LoginController::logincheck() - APP\controllers\login_controller.php,
line 37
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 268
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 240
Object::requestAction() - CORE\cake\libs\object.php, line 105
HomeController::beforeFilter() - APP\controllers\home_controller.php,
line 10
Dispatcher::start() - CORE\cake\dispatcher.php, line 312
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 226
[main] - APP\webroot\index.php, line 89


if i move the code from logincheck function in login_controller to
beforefilter in home_controller the problem is gone,  so the real
problem is the requestAction. Is there any other workaround?


my login_controller :
-----------------------------
<?php
class LoginController extends AppController{
        var $name = 'Login';
        var $helpers = array('Html', 'Javascript');
        var $uses = array('Admin');
        var $layout = 'cpanel';

        function index(){
                if($this->Session->read('admin_id')){
                        $this->redirect('/home/');
                }
                $this->pageTitle='Control Panel :: Login';
                $this->set('username_error', 'Username Must be Filled');
                $this->set('password_error', 'Password be Filled');
                if($this->data){
                        $this->Admin->set($this->data);
                        if($this->Admin->validates()){
                                
if($login=$this->Admin->findByUsername($this->data['Admin']
['username'])){
                                        if($login && 
$login['Admin']['password']==md5($this->data['Admin']
['password'])){
                                                
$this->Session->write('admin_id', $this->data['Admin']
['username']);
                                                $this->redirect('/home/');
                                        }else{
                                                $this->set('password_error', 
'Invalid Password ');
                                                
$this->Admin->invalidate('password');
                                        }
                                }
                                else{
                                        $this->set('username_error', 'Username 
not Registered');
                                        $this->Admin->invalidate('username');
                                }
                        }else{
                                $this->validateErrors($this->Admin);
                        }
                }
        }
        function logincheck(){
                if($this->Session->check('admin_id')){
                        return true;
                }else{
                        $this->Session->setFlash('Not logged-in or session 
timeout', null,
null, 'login');
                        $this->redirect('/login');
                        exit();
                }
        }
}
?>


my other controller (in this case home_controller)
-----------------------------------------------------------------------
<?php
class HomeController extends AppController{
        var $name = 'Home';
        var $helpers = array('Html', 'Javascript');
        var $uses = array('Admin', 'Modul');
        var $layout = 'cpanel';

        function beforeFilter(){
                $this->requestAction('/login/logincheck');
        }
        function index(){
                $this->pageTitle='Control Panel';
                $this->set('moduls', $this->Modul->findAll("status = '1'"));
        }
        function logout(){
                $this->Session->delete('admin_id');
                $this->redirect('./');
        }
}
?>

--~--~---------~--~----~------------~-------~--~----~
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