Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Description


Core\Auth\User auth()


Using our auth() function will give you access to our core authentication class.

Examples


<?php

route('/foo', function() {

   // Check if a user is logged in
   if (auth()->isLoggedIn()) {
      echo "Hello logged in user!";
   }

   // Check if the user is an admin
   if (auth()->isAdmin()) {
      echo "Hello Admin!";
   }

});


route('/bar', function() {

   // This will redirect the user if they are not logged in
   auth()->membersOnly();

});

Methods


MethodDescriptionUsageReturns
isLoggedIn()

Check if a user is logged in or not.

if (auth()->isLoggedIn()) {
	echo "Hello logged in user!";
}
true if logged in, false if not
  • No labels