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

gidaban79's avatar

How to show message after verify email ?

Hello guys :)

i wish to display message when user will click on link in verification email,

After click, redirect on website and show message "Thanks" :)

0 likes
10 replies
gidaban79's avatar

How about something more dynamically?

Session::flash ? is possible to do ?

Snapey's avatar
Snapey
Best Answer
Level 122

You can copy this function from the trait to the verification controller and then change it how you like;

    /**
     * Mark the authenticated user's email address as verified.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     * @throws \Illuminate\Auth\Access\AuthorizationException
     */
    public function verify(Request $request)
    {
        if ($request->route('id') != $request->user()->getKey()) {
            throw new AuthorizationException;
        }

        if ($request->user()->markEmailAsVerified()) {
            event(new Verified($request->user()));
        }

        return redirect($this->redirectPath())->with('verified', true);
    }

for instance, before the return;

        Session::flash('success', 'Your email has been verified');

        return redirect($this->redirectPath())->with('verified', true);

and then also change the last line to redirect wherever you want.

3 likes
david_nash's avatar

Just came across this, as I wanted to show an alert on verification.

There's now an empty verified() method in the trait, so in VerificationController.php I just needed to add this:

    protected function verified(Request $request)
    {
        $request->session()->flash('alert', [
            'status' => 'success',
            'body' => 'Your email has been verified. Thanks!'
        ]);
    }

and don't forget to add use Illuminate\Http\Request; to the top of the controller.

4 likes
Online-Marketing's avatar

I used this in Laravel 8

Add the following to VerificationController.php:

use Illuminate\Http\Request;

/**
     * Show Success Message after E-Mail verified successfully
     * @param Request $request
     */
    protected function verified(Request $request)
    {
        $request->session()->flash('success', 'Email adress successfully verified');
    }
1 like
lignuss's avatar

I also want to write such a message and have been dealing with it. I noticed that after the verification in the session is the following:

"verified" => true

So can I dispense with the procedure from above and simply query this session variable? Or does this mean something else?

jasonfrye's avatar

With Fortify it appears to be adding ?verified=true to the path. I've added the following to handle showing an alert.

@if(request()->query('verified'))
     <div class="alert alert-success" role="alert">
           Email address verified!
     </div>
@endif	

Please or to participate in this conversation.