Monday, November 29, 2010

$_SESSION contains my data but $Session helper is empty.

I'm using Cake v1.3.5 and I'm trying to simply set a flash message in
the controller and display it in the view. When I pr() my $_SESSION
data I can see the message that was set. But the Session helper
apparently does not know about it. (The Session component, however,
can read it right back out of the session.)

Controller:
$this->Session->setFlash('No password entered.');

View:
<?php

pr($_SESSION);
pr($session->read('Message'));

if ($session->check('Message.flash')) { echo $session->flash(); }

?>

Output from the pr() calls above:

$_SESSION (successfully retains the setFlash values):
Array
(
[Message] => Array
(
[flash] => Array
(
[message] => No password entered.
[element] => default
[params] => Array
(
)

)

)

[urlBackTrack] => Array
(
[0] =>
[1] =>
[2] =>
[3] => /users/log_in
[4] => /users/log_in
)

)

$session->read('Message'): Nothing!!!

Even if I pr($session) -- the session Helper Object itself -- it gives
me helper properties but no actual session information:

SessionHelper Object
(
[helpers] => Array
(
)

[__active] => 1
[valid] =>
[error] =>
[_userAgent] => dbecc025bb81ed93c9d1a29b62c7bb07
[path] => /
[lastError] =>
[security] => low
[time] => 1291063357
[sessionTime] => 1291099357
[cookieLifeTime] => 2160000
[watchKeys] => Array
(
)

... etc


So, if PHP sessions are working, but Cake is not, then it is something
about Cake's session wrapper functionality that is problematic. My
core.php has:

Configure::write('Session.save', 'php');
Configure::write('Session.timeout', '120');
Configure::write('Session.start', true);
Configure::write('Session.checkAgent', true);
Configure::write('Security.level', 'low');

Why isn't the Session helper working?

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en

No comments: