<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Laravel 5.8 Auth::guard($guard)-&gt;check() always return false]]></title><description><![CDATA[<p dir="auto">I have two separate logins using guards which customer &amp; adminuser. I have checkRole middleware for adminuser login and it works perfectly. I used guest middleware (RedirectifAuthenticated) to customer login. When customer login check with Auth::guard($guard)-&gt;check() it always returns false. But Auth::guard('customer')-&gt;attempt returns true. I can't find a solution.</p>
<p dir="auto">here is the login controller for customer</p>
<pre><code>class LoginController extends Controller
{

    use AuthenticatesUsers;

    public function __construct()
    {
       $this-&gt;middleware('guest:customer')-&gt;except('customerlogout');
    }

    //login the customer
    public function customerLogin(Request $request)
    {
        $email = $request-&gt;get('email');
        $password = $request-&gt;get('password');
        
        
        //Getting user inputs and authenticate the customer
        $status = Auth::guard('customer')-&gt;attempt([
            'email' =&gt; $email, 
            'password' =&gt; $password ] 
            );

        //Check login  
        if ($status) {
            //if login pass,redirect to customer account page
            return redirect()-&gt;intended('/customer_account');
            
         }else{
             //if login fail,redirect back to home page
             return redirect()-&gt;back();
         }
    }
    
    //logout the customer
    public function customerlogout(Request $request)
    {   
        Auth::guard('customer')-&gt;logout();
        $request-&gt;session()-&gt;flush();
        return redirect('/index');   
    }
}
</code></pre>
<p dir="auto">here is the guest middleware</p>
<pre><code>    public function handle($request, Closure $next, $guard = null)
    {       
        if ($guard === "customer" &amp;&amp; Auth::guard($guard)-&gt;check()) {
            return redirect('/customer_account');
        }
        if (!Auth::guard($guard)-&gt;check()) {
            return redirect('/index');
        }
        return $next($request);
    }
</code></pre>
<p dir="auto">Any help is appreciated, thanks!</p>
]]></description><link>https://lankadevelopers.lk/topic/560/laravel-5-8-auth-guard-guard-check-always-return-false</link><generator>RSS for Node</generator><lastBuildDate>Mon, 10 Aug 2026 04:47:08 GMT</lastBuildDate><atom:link href="https://lankadevelopers.lk/topic/560.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 12 Apr 2020 06:37:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Laravel 5.8 Auth::guard($guard)-&gt;check() always return false on Tue, 14 Apr 2020 18:40:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://lankadevelopers.lk/uid/297">@hashan</a></p>
<p dir="auto">check this out</p>
<p dir="auto"><a href="https://laracasts.com/discuss/channels/laravel/why-my-custom-authentication-with-guard-not-working" target="_blank" rel="noopener noreferrer nofollow ugc">https://laracasts.com/discuss/channels/laravel/why-my-custom-authentication-with-guard-not-working</a></p>
]]></description><link>https://lankadevelopers.lk/post/3287</link><guid isPermaLink="true">https://lankadevelopers.lk/post/3287</guid><dc:creator><![CDATA[root]]></dc:creator><pubDate>Tue, 14 Apr 2020 18:40:58 GMT</pubDate></item><item><title><![CDATA[Reply to Laravel 5.8 Auth::guard($guard)-&gt;check() always return false on Tue, 14 Apr 2020 04:39:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://lankadevelopers.lk/uid/1">@ciaompe</a> yh i checked. it returns the correct guard value</p>
]]></description><link>https://lankadevelopers.lk/post/3285</link><guid isPermaLink="true">https://lankadevelopers.lk/post/3285</guid><dc:creator><![CDATA[hashan]]></dc:creator><pubDate>Tue, 14 Apr 2020 04:39:03 GMT</pubDate></item><item><title><![CDATA[Reply to Laravel 5.8 Auth::guard($guard)-&gt;check() always return false on Sun, 12 Apr 2020 09:02:53 GMT]]></title><description><![CDATA[<p dir="auto">can you dd($guard) and check the $guard value ?</p>
]]></description><link>https://lankadevelopers.lk/post/3279</link><guid isPermaLink="true">https://lankadevelopers.lk/post/3279</guid><dc:creator><![CDATA[ciaompe]]></dc:creator><pubDate>Sun, 12 Apr 2020 09:02:53 GMT</pubDate></item></channel></rss>