Auth::check returns false in AppServiceProvider
<p>I have tried injecting the Guard contract into the constructor, I have tried moving around. But when a user is logged in - Auth::check() returns false.     </p>

<p>In other files (Except 1 global middleware) Auth::check() works correctly.
In the middleware - moving Auth Check to the top helped alleviate the issue. In this case - it isn't working.  </p>

<p>Additional information: This app has been upgraded from 4.2 . Previously it used Confide.</p>

<pre><code>&lt;?php

namespace App\Providers;

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{

        /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        if(Auth::check())
        {
            $user = Auth::user();
            $messages=Message::where('read',0);
            $messages-&gt;where(function ($query) use ($user) {
                $query-&gt;where('to',$user-&gt;id)-&gt;orwhere('from',$user-&gt;id);
            });
            $message_unread= $messages-&gt;count();

            $new_notifications= Notification::where('user_id',$user-&gt;id)-&gt;where('viewed',0)-&gt;count();            
        }
        else
        {
            $message_unread=0;
            $new_notifications=8888888;
</code></pre>

<p>//its 888888 for testing purposes.</p>

<pre><code>        }

        view()-&gt;share(([
            'message_unread'=&gt;$message_unread,
            'new_notifications'=&gt;$new_notifications
        ]));
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
</code></pre>