search

Home  >  Q&A  >  body text

php - Laravel 5.4 AUTH - Auth::guard('admin')->user() After logging in, other pages are taken out as NULL

Use

when logging in

1

2

<code>Auth::guard('admin')->attempt([])

</code>

Returns true, then prints it with dd

1

2

<code>dd(Auth::guard('admin'))

</code>

Login to this page is possible. Then when jumping to other pages, print again

At this time, because the user attribute is empty, so

1

2

3

<code>Auth::guard('admin')->user() == null

Auth::guard('admin')->check() == false

</code>

Excuse me which step is wrong

伊谢尔伦伊谢尔伦2853 days ago1037

reply all(3)I'll reply

  • 巴扎黑

    巴扎黑2017-05-16 13:16:29

    Check whether the session_domain setting is correct

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-16 13:16:29

    Both pages are directly dd?

    Directly dd after logging in, resulting in no session being written.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-16 13:16:29

    Have you included cookies in your redirect page? . . You didn’t add it to Kernel.php

    1

    2

    3

    4

    5

    6

    7

    8

    9

    <code>        \App\Http\Middleware\EncryptCookies::class,

            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,

            \Illuminate\Session\Middleware\StartSession::class,

            \Illuminate\View\Middleware\ShareErrorsFromSession::class,

            \App\Http\Middleware\VerifyCsrfToken::class,

            \Illuminate\Routing\Middleware\SubstituteBindings::class,

            \App\Http\Middleware\RedirectIfAuthenticated::class,

             

            类似的中间件</code>

    reply
    0
  • Cancelreply