Support the ongoing development of Laravel.io →
posted 3 years ago
Lumen

I am trying to set a session flash message in blade file in lumen 8. However it's stated a pervious version but not present in latest doc.

Here is my code snippet

In Controller:

public function foo()
{
  ....
  return redirect('contact')->with('status', 'Message sent successfully !');
}

In blade:

@if (session('status'))
    <div class="alert alert-success">
        {{ session('status') }}
    </div>
@endif

But it's not working & throwing an error

Call to undefined function Session()

How can I set a flash message in blade after redirect ?

Last updated 3 years ago.
0

You can not directly use Session in Blade tamplate.

First you need to use ill..\Session:class In middleware..

0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.