Friday, March 30, 2012

Re: Controller can't access the Session

i also came across same problem.... i arranged the code such that after initialising session.. read the variables in session....and not put other codesbetween this.. if u do it.. u can get the result.. 

On Fri, Mar 30, 2012 at 12:19 AM, Miles J <mileswjohnson@gmail.com> wrote:
On a side note, you are including tons of models.

You don't need to include every model if specific models have associated models you can utilize. You should also load models on a per action basis using loadModel().

On Sunday, March 18, 2012 5:37:02 PM UTC-7, Felipe Roman wrote:
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@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php



--
Litto Chacko
Axtec Softwares

--
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@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: