dismiss this, I am returning my view instead or redirecting and it works.
How to Flash messages in same page without redirecting?
Does anyone know how to do this? If I remove the redirect from the code I will only get a blank page.
Session::flash('message', "my message");
return Redirect::back();
You can do that by using "now($key, $value)"
session()->now('message', 'Success! message.');
I see this in the Store class, and I'm trying to use if but it's not working.
session()->now('success', 'The client was updated successfully.');
Nothing at all. I also tried:
session()->now('success', 'The client was updated successfully.');
session()->reflash();
No love on flash at all without a redirect, I'm using Inertia so there's no redirect here.
@vkronlein if you want help, start a new question, not add to a three year old one that is not even related to your issue
How is it not related? I'm having this exact problem, I need to flash on an existing page.
This question has no answer yet ... no reason to open a new one, I searched and found this open one.
Sorry if this isn't the proper way, I'm used to SO where you get hammered for not searching to find the answers before you open a new question.
I doubt the three year old question was related to inertia. In your case it is critical to your problem.
Flashing a message without redirecting is not an Inertia issue. It's a Laravel issue. I only wrote that I was using Inertia as an aside in hopes it might lead to a faster resolution. Though using Inertia did lead to a much faster and simpler answer.
But thank you for hopping in here and helping with the issue.
.... oh wait ....
Flashing a message requires that the blade view is rendered. You render a view in response to a get request.
php session data cannot just magically appear in the client.
The original question was answered by the OP himself if you check above.
`use Session;
Session::flash('message', "my message");
return Redirect::back();`
getting error Redirect not found, I am using Laravel 11.x version. Thanks.
Please or to participate in this conversation.