Monday, June 29, 2009

Flash messages and Session Destroy

Hi Guys,

I have a slight issue and I suspect its related to how Session-
>destroy works.

If I destroy a session, and then set a flashmessage, it never appears
or exists in the page after I redirect. For example, when a use logs
out, I set a message after Session->destroy to "you have been logged
out".

The other scenario is if a user logs in, and there is already a user
logged in, I destroy the session, and then log the user in, which is
suppose to set the the user details into the session. However,
anything set after the Session->destroy is lost.

My redirects are also only set last. So first Session->destroy, then
Session->setFlash, and then finally Session->redirect.

I looked at the SessionComponent file an thought the following lines
looked incorrect...

function destroy() {
if ($this->__active === true) {
$this->__start();
parent::destroy();
}
}

Surely it should be:

function destroy() {
if ($this->__active === true) {
parent::destroy();
$this->__start();
}
}

I changed it to test, and the second scenario above worked fine,
however, my setFlashes are still getting lost.

Is this correct, is there possible something I should be doing?

Much appreciated.

G


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