Saturday, June 25, 2016

[Solved] Auth Check not working on Laravel 5.*

Problem :
I want to check if user has logged in or not, when I try
@unless (Auth::check())
    you are not logged in
@endundless

the Auth Check always return false.

Solution:
Use Auth::user() instead of Auth Check, so the code will be like :
@if (isset(Auth::user()->id))
      <h1>sudah login</h1>
@else
       <a href="{{ URL::to('auth/register') }}">Login</a> | <a href="{{ URL::to('auth/register') }}">Daftar</a>

 @endif     

No comments:

Post a Comment