Skip to content

Flash message doesn't get purged #1298

@damsfx

Description

@damsfx

Winter CMS Build

dev-develop

PHP Version

8.1

Database engine

MySQL/MariaDB

Plugins installed

None

Issue description

A flash message is displayed at the page load after a redirection and displayed again at the page refresh.

Steps to replicate

Two pages having their own component: page 1/component A, page 2/component B.

Form the page component A, I make a redirect to page 2.

// component A
public function onRun()
{
    trace_log('Component A::onRun');
    return Redirect::to('my-page')->with('message', 'My awesome message');
}

In page 2 / component B :

// component B
public function onRun()
{
    trace_log('Component B::onRun');

    $returnMessage = Session::pull('message');

    if ($returnMessage) {
        Flash::warning($returnMessage);
    }
}

When page 2 is displayed after redirect, the flash message is show.
If page 2 is refreshed a first time (or accessed through a link, or refresh a page in backend your logged in) it show the flash message a second time.
If page 2 is refreshed a new time there is no more flash message.

[2025-01-24 15:21:04] development.INFO: Component A::onRun
[2025-01-24 15:21:05] development.INFO: Component B::onRun    // Flash message is displayed
// refresh the page
[2025-01-24 15:21:15] development.INFO: Component B::onRun    // Flash message is displayed  
// refresh the page
[2025-01-24 15:21:15] development.INFO: Component B::onRun

Workaround

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedIssues that have been accepted by the maintainers for inclusion

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions