Laravel 9.x: Redirect user to view success message after registration
P粉983021177
P粉983021177 2023-11-12 22:55:21
0
1
692

I'm trying to return a view with a success message after registering a user, with a link to the login page, but the session message is not passed along with the view.

This is myregistred()method

protected function registered(Request $request, $user) { return view('frontend.pages.register-success')->with('message', 'Your registration was successful. Click the button below to login to your account'); }

This is the view page

@extends('frontend.layouts.main') @section('title', 'Registration successful') @section('content')  
@if (Session::has('message')) @endif
@endsection


P粉983021177
P粉983021177

reply all (1)
P粉054616867

We can use the session() global helper instead of Session:

// flash message create session()->flash('message', 'This is a message!'); session()->flash('alert-class', 'alert-danger');

Get flash messages by keystroke from your blade file

@if(session()->has('message'))
           @endif
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!