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

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

You can use the @auth directive.

  1. @auth
  2.              Hello, logged in user!
  3. @endauth

Related: @guest to check if user is a guest (not logged in)

  1. @guest
  2.             Hello guest, do you want to register?
  3. @endguest

webdevetc profile pic
webdevetc

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This (webdevetc.com) is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.



More...


Comments and discussion about How to check if a user is logged in, inside a blade file?

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the Laravel language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

What is the difference between reference and primitive data types types in Javascript?

What are Template literals (Template strings) in JS?

How to eager load multiple levels of relationships in Eloquent?

How to check if a relation was loaded on an Eloquent model already?

How to round a number in JS?

How to enable the rewrite engine in .htaccess?

How to show (or log) all SQL queries executed by Laravel

How to block access to certain referrers in Apache using .htaccess

How to generate an array for a dropdown (with ['key' => 'value']) suitable for a dropdown, from a Laravel collection of Eloquent objects?

How to use Anonymous classes in PHP 7?