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

Leff7's avatar
Level 4

Laravel 5.3 - How to keep the session message until the users logs out

I am sending a welcome message to user after registration. I have modified the trait method in my controller like so:

    public function register(Request $request)
    {
        $this->validator($request->all())->validate();

        event(new Registered($user = $this->create($request->all())));

        $this->guard()->login($user);

        Session::set('message','messages.welcome');

        return redirect($this->redirectPath())->with('message', 'messages.welcome');
    }

And then I am showing the message in the view like this:

@if (session('message'))
   @include(session('message'))
@endif

But when I refresh the view the messages disappears, how can I keep the messages until the user logs out?

0 likes
0 replies

Please or to participate in this conversation.