cake-php@googlegroups.com
[Top] [All Lists]

Controller can't access the Session

Subject: Controller can't access the Session
From: Felipe Roman
Date: Sun, 18 Mar 2012 21:37:02 -0300
Hi,

Has someone ever seen only one controller does not access the cake session ?

The session works fine for all controllers except for one specific
controller. I tried debug the problem but I didn't find the reason.

The controller code:

class ExecutivosController extends AppController {

        var $name = 'Executivos';
        var $uses = array('Executivo', 'FormacaoAcademica',
'FormacaoComplementar', 'Executivo', 'Empresa', 'Unidade', 'Cargo',
'ExecutivoCargo', 'AtuacaoProfissional', 'ExecutivoIdioma', 'Decisao',
'Mobilidade', 'PotencialProntidao', 'Arquivo', 'Usuario');
        var $components = array('RequestHandler', 'Email');

        function index() {

                // Get login information
                $Login = $this->Session->read('Login');

                debug($_SESSION);
                debug($Login);

and the others controllers are similar:

<?php
class CargosController extends AppController {

        var $name = 'Cargos';
        var $uses = array('Cargo', 'Empresa', 'Unidade', 'Executivo',
'RespostaColaboradore');
        var $components = array('RequestHandler', 'Email');

        function index() {
            // Le informações de login
            $Login = $this->Session->read('Login');

            debug($_SESSION);
            debug($Login);


When I access the Cargos controller all session information are
printed by debug funcion as expected, when I try access the first one
the Session and $_SESSION is empty. If I reload the second one again
the session values are still there (it means the session isn't
erased).

The app_controller.php file:

class AppController extends Controller {
    var $helpers = array('Html', 'Javascript', 'Session', 'Ajax',
'Time', 'Form');

    function  beforeFilter() {
        //debug($this);
        if (($this->name != "Usuarios") or ($this->action != 'login')){

            if($this->Session->read('Login')) {
            } else {
                $this->Session->setFlash(__('Efetue o login para
acessar o sistema', true));
                $this->redirect(array('controller' => 'usuarios',
'action' => 'login'));
            }
        }
    }

Has someone have any ideas why the Executivos controller can't access
the session ?

Thanks

-- 
Best Regards,
Felipe Roman
Phone 55 51 8454 8110
LinkedIn http://au.linkedin.com/in/feliperoman

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@xxxxxxxxxxxxxxxx For more options, visit this group at 
http://groups.google.com/group/cake-php

<Prev in Thread] Current Thread [Next in Thread>