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

Alizey's avatar

How to show successful login message

I am using Laravel 5 default login functionality and its works fine . I only want's to how how can i show message when some user login with their name. Let suppose Welcome back John Doe etc. When User Login On Home page ?

0 likes
11 replies
umefarooq's avatar

with successfull redirect send message

redirect('/')->with('success', 'You are successfully logged in');

on home page or in master blade layout add this

@if(Session::has('success'))
<div class="alert alert-warning alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
{{Session::get('success')}
</div>
@endif
1 like
Alizey's avatar

@umefarooq How can i attach with with this one ?

public function redirectPath()
    {
        if (property_exists($this, 'redirectPath'))
        {
            return $this->redirectPath;
        }

        return property_exists($this, 'redirectTo') ? $this->redirectTo : '/';
    }
Alizey's avatar

its a function that redirect user to your specific path after login. How can i add with there ?

umefarooq's avatar

this method just returning value of redirect path show method which has redirect method

Alizey's avatar

This one ?

public function handle($request, Closure $next)
    {
        if ($this->auth->check())
        {
            return new RedirectResponse(url('/dashboard'));
        }

        return $next($request);
    }
umefarooq's avatar

Here you can add

 return new RedirectResponse(url('/dashboard'))->with('success', 'You are successfully logged in');
Alizey's avatar

Not working :( syntax error eccors

davorminchorov's avatar

Try adding that with() method inside like:

 return new RedirectResponse(url('/dashboard')->with('success', 'You are successfully logged in'));
umefarooq's avatar
Level 5

better to try this

return redirect('/dashboard')->with('success', 'You are successfully logged in'); 

it work the same as RedirectResponse

1 like

Please or to participate in this conversation.