Posts

Showing posts from August, 2021

Laravel Login & Logout Using Session & Middleware

 Create Middleware : LoginMiddleware  <?php namespace   App\Http\Middleware ; use   Closure ; use  Illuminate\Http\ Request ; use  Illuminate\Support\Facades\ Session ; class   LoginMiddleware {      public   function   handle ( Request   $request ,  Closure   $next )     {          if (! $user  =  Session :: get ( 'user' )){              return   redirect ( 'login' );         } else  {              return   $next ( $request );         }     } } Now Register Middleware in App/Http/kernal.php     protected   $routeMiddleware  = [           'loginAuth' ...