solution. I changed the app/config/core.php file setting:
Session.checkAgent to false so the Ajax requests do not change the
UserAgent allowing the controller to get the session.
"Session.checkAgent
Setting this to TRUE means Cake will store the user agent header of a
request when a new session is created. On subsequent request, the user
agent header sent is compared with the value stored in the session. If
it does not match, the current session will be destroyed and a new
session gets created.
This rarely causes problem unless you have embedded Flash or Java
objects making separate requests to the application. You must take
note to send the user agent string of the browser in that case. If you
are using something like Aurigma's Image Uploader where the user agent
is not configurable, you have to set this to FALSE instead."
Source
http://derickng.com/posts/36-cakephp-losing-or-missing-session
Thanks
On Mar 19, 7:50 am, euromark <dereurom...@googlemail.com> wrote:
> why don't your controllers have:
>
> public $components = array('Session');
>
> ?
>
> without it you cannot use the session component
>
> Am Montag, 19. März 2012 01:37:02 UTC+1 schrieb Felipe Roman:
>
>
>
>
>
>
>
>
>
> > 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
> > LinkedInhttp://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
No comments:
Post a Comment