Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

George12's avatar

Redirect to route with data

Is it possible to redirect to a named route with data? Something like:

return redirect()->route('homepage',  ['message']);

I do not want to send the data as GET parameter, but as a variable.

Thanks

0 likes
4 replies
kingpabel's avatar

@SaeedPrez is right

return redirect('dashboard')->with('status', 'Profile updated!');
@if (session('status'))
    <div class="alert alert-success">
        {{ session('status') }}
    </div>
@endif
2 likes
SaeedPrez's avatar

@kingpabel

Thanks for repeating/confirming my answer and pasting the documentation example I linked to, I don't know what I would have done without you :)

Without your post, he actually would have had to click once (OMG!) to get the exact same information.

1 like
rafidAhsan's avatar

$message = 'Your seial is '.rand(1, 100);

return redirect('/')->with('msg', $message);

Please or to participate in this conversation.