Laravel | How to check if a user is logged in, inside a blade file?

10-Apr-2023

.

Admin

Hello Dev,

If you have to check user login or not in laravel blade then it's provide directives. also you can check guest user in blade with directives. If needed, you may specify the authentication guard that should be checked when using the @auth and @guest directives.laravel check if user is logged in blade. in Blade check if user is logged in.

Only Login and Guest


@auth

// The user is login...

@endauth

@guest

// The user is not login...

@endguest

Check Login and Guest With Guard

@auth('admin')

// The user is login with admin...

@endauth

@guest('admin')

// The user is not login with admin...

@endguest

I hope it can help you...

#Laravel