Redirect with not working Just started playing with Laravel and even though I'm following tutorials - the with function doesn't seem to work!
return Redirect::route('projects.tasks.show', [$project->slug, $task->slug])->with('message', 'Task updated.');
The page redirects but I can't access the session variable. I have tried
session()->flash('message','TEST');
and this works fine.
Anyone else had this problem?
Hi thanks for replying.
I have tried using the
redirect()->route('myRoute')->with('message','TEST')
rather than
Redirect::route('myRoute')->with('message','TEST')
As well as
redirect('http://myURL')->with('message','TEST')
And they all have the same problem - the page does redirect correctly, but without the session flash variable.
I did look at the documentation, but it just mentions the "with" method quickly - as if it should work out of the box!
Just realised that it's more to do with sessions not persisting!
garcard, I just had the same problem, what I realized is that there was a second redirect happening.
return redirect()->to('/')->with('message', 'Thank you for updating your billing information.');
Once I realized that / actually went to home I changed the code to:
return redirect()->to('/home')->with('message', 'Thank you for updating your billing information.');
And the message was actually there.
Hi all,
It's a bit old topic but i tried almost everything and nothing worked for me except adding "->send()" at the end:
return redirect()->to('/home')->send();
Hope this help someone looking for a solution for the redirect problem.
Regards.
@Ado666 Thank you so much!
Spent long time on redirect function to work but without avail, not even laravel doc mentions this!
@Ado666 Saved me another five hours...thought I tried everything and this still works in version 8
Thanks!
@Ado666 I was going nuts trying to solve why my redirect wasn't working. ->send() made it work. Thank you!
@ADO666 - Spent the whole day trying to fix this problem I found your post - And yes indeed it helped me ! Thanks !
This thread is old, im using laravel 7.x and i just bumped on this. adding the send() after the chains made it work.
Thanks for this @ado666
Same for me, even later. Thanks for this @ado666
Alhamdulillah. It works. Just add ->send()
Hello, every one just resolved this issue in Laravel 7 (Redirecting With Flashed Session Data ). let me know if still someone struggling to solve this issue.
@hems would be more productive if you just share your solution.
Hello,
Same problem here, if I use
Session::put('message', 'Test'), it's working but remain forever in front end
after session::put I have return redirect('/') and it shows me the message but with "with" not working in laravel 8
Had the same issue in Laravel 10.19
Could not understand why
return redirect()->route("install",['s'=>2])
Was not working, but
return redirect()->route("install",['s'=>2])->send();
works perfectly.
As someone mentioned previously, this solution isn't mentioned in the manuals.
@ado666 ->send() also worked for me to fix this issue, still working in laravel 10. you saved me so much time, thank you
Please sign in or create an account to participate in this conversation.