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.

What is the right way to clear Flash Session?

I'm outputing flashSession in my View using this method - flashSession.output(). When i reload the page the flash messages are still there. How can i remove them in a right way? Sequence like this does not work: flashSession.output(). flashSession.clear().



7.7k
Accepted
answer

This should work automatically flashSession.output(), output has one parameter $remove and its default value is true. Looks like you are populating flash messages on reload again.



10.1k

yes you are right, when reload the page, i re-submit my form again and get the messages again. Thnx



118

@Paul, so, what did you do to solve this problem?



10.1k
edited Apr '18

@biyro02, Hey, it was long ago, but I've just looked into it for you :)

I moved flashout elsewhere and no longer used it to display entered values in my form. Instead I used session post vars in the value attribute as you can see below:

Look at this line <input type='text' name="month" class="form-control" *value="{% if postVars['month'] is defined %}{{ postVars['month']}}{% endif%}" />

<div class="col-md-3 columns">
                    <div class="form-group">
                        <label for="name">Select Month:</label>
                        <div class='input-group date' id='datetimepicker1'>
                            <input type='text' name="month" class="form-control" *value="{% if postVars['month'] is defined %}{{ postVars['month']}}{% endif%}" />
                            <span class="input-group-addon">
                                <span class="glyphicon glyphicon-calendar">
                                </span>
                            </span>
                        </div>
                    </div>
                </div>

The whole page code you can find on my Github page



118

@paul, thank you for your answer. I have the same error but I didn't see any solution. My project is huge. This is not coded by mine. So, there are many flash.output using. I can not try this way. Now, I used flashSession->clear, flashSession->getMessages(false) and flashSession->setAutoScape(false) methods. Now I have a very interesting and difficult the explain error. I hope I will solve. Thanks again!