We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

FlashSession bug in Phalcon 2.0.2

Hello,

There seems like a bug in the FlashSession functionality in Phalcon 2.0.2. In an Authentication Controller, I used this line to set an error message when the authentication failed.

$this->flashSession->error('Could not login user');

The message is added to the session, but without a HTML element and CSS class. Below a var_dump from the getMessages() output.

$this->flashSession->getMessages()

This is the output with var_dump

array (size=1)
  'error' => 
    array (size=1)
      0 => string 'Could not login user' (length=20)

This functionality is working properly for FlashDirect

$this->flash->error('Could not login user');

That line create this output

<div class="errorMessage">Could not login user</div>

I do not see what I'm doing wrong.

HTML is added on render, why store unneeded bytes in the session?



1.2k

I need the error message after a redirect. That's why I use flashSession.



1.2k

The problem is solved by simply adding this to the Volt template:

{{ flashSession.output() }}


6.4k
Accepted
answer

What I mean is that it is not necessary to store <div class="errorMessage"></div> in the session, all it does is take up more storage space, so it's not a bug



1.2k

Oscar,

Thank you for the reply. I think I understand you. Only the messages (without the class) are stored in the session. The flashSession::output function read the messages from the session and add <div class="errorMessage"></div> around the messages.