Laravel Framework uses AUTH asynchronous login to access other pages without login user information

Source: Internet
Author: User
1, the use of Laravel auth verification
2. Change the model in configuration auth.php to Appmodelsadminuser::class (because it is the login authentication of the background user)
3, in the page with Ajax call Background login method, the main logic is as follows:

if (auth::attempt (' name ' = = $request->input (' name '), ' password ' = ' = $request->input (' password ')])) {

            // 认证通过...            dd(Auth::user());        }

I was able to see in the browser console the back of the DD login user information, but at this time to another page to print Auth::user (), then null, where is the problem?

Reply content:

1, the use of Laravel auth verification
2. Change the model in configuration auth.php to Appmodelsadminuser::class (because it is the login authentication of the background user)
3, in the page with Ajax call Background login method, the main logic is as follows:

if (auth::attempt (' name ' = = $request->input (' name '), ' password ' = ' = $request->input (' password ')])) {

            // 认证通过...            dd(Auth::user());        }

I was able to see in the browser console the back of the DD login user information, but at this time to another page to print Auth::user (), then null, where is the problem?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.