Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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?

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

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

{{ flashSession.output() }}


6.3k
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

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.