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

cytisay's avatar

Symfony\Component\HttpFoundation\RedirectResponse::__construct(): Argument #2 ($status) must be of type int, array given

My goal is to pass the name of the user after a successful login so I can display it on the dashboard page. Here's the line of code that causes the error which is inside the AuthenticatedSessionController:

$user_name = Auth::user()->name;
return redirect()->intended($url, compact('user_name'));

Is there other way to display the user's information after logging in? I am using Laravel + Inertia + VueJS and Vuetify. Please help.

0 likes
12 replies
tisuchi's avatar

@cytisay Try this:

return redirect()->intended($url)->with('user_name', $user_name);
1 like
cytisay's avatar

@tisuchi hello, sir. it doesn't cause any error anymore. but how do i display its value on a VueJS component file? I tried Welcome, {{$user_name}} but it doesn't display anything.

tisuchi's avatar

@cytisay This could be a way.

Your controller

$user_name = Auth::user()->name;
return redirect()->intended($url)->with('user_name', $user_name);

Your vue:

<template>
  <div>
    Welcome, {{ userName }}
  </div>
</template>

<script>
export default {
  props: {
    userName: String
  }
}
</script>
PovilasKorop's avatar

@cytisay not the direct answer to your question but maybe you don't need to pass the username if it's the name of the logged-in user? It is available by default in Laravel as auth()->user()->name on any page.

cytisay's avatar

@PovilasKorop hello, sir. where should I put this auth()->user()->name? i tried using it on my vue file but it cannot read the auth. I also tried the $page.props.auth.user.name as indicated on the Laravel Breeze starter kit but I am only receiving an error like this: TypeError: Cannot read properties of undefined (reading 'user').

PovilasKorop's avatar
Level 11

@cytisay try $page.props.user.name from what I remember. Those properties are in the middleware HandleInertiaRequests

cytisay's avatar

@PovilasKorop

Hello, again, Sir. I watched your Vue Inertia + Laravel Course and in Lesson 16: User Data from Auth, I solved my problem. I didn't know that I needed to edit my HandleInertiaRequest file, so to solve my problem, I added this block of code (as I learned from your video):

'user' => [
   'first_name' => auth()->user()->first_name,
   'last_name' => auth()->user()->last_name,
   'email' => auth()->user()->email,
]

I understand how it works now, Sir, thank you very much. This $page.props.user.email works for me in my case because of my code structure, while the $page.props.auth.user.email causes an error. Based on my understanding, if I am to use $page.props.auth.user.email, the code in HandleInertiaRequest should be something like this, as indicated on the laravel breeze starter kit:

'auth' => [
   'user' => $request->user(),
],

I learned a lot form your course so thank you, sir! Have a great day!

1 like
Snapey's avatar

you are redirecting to another route and controller. In the target controller get the name. You don't need to pass it along.

Just jeep learning and experimenting, it will come to you

cytisay's avatar

@Snapey thank you, sir. i am a beginner in Laravel and started only this month so i'm having a hard time understanding how the back end works.

Please or to participate in this conversation.