Laravel How do I get the login log for a user?

Source: Internet
Author: User
The Laravel version used is 5.2,
I want to record the user registration and time and IP address of each login,
How do you do it?

Reply content:

The Laravel version used is 5.2,
I want to record the user registration and time and IP address of each login,
How do you do it?

Login events are provided in the framework event provided by Laravel and can be directly used

The registration time is written in the user table, which is determined when it is created, and the logon time is written in the login log table.
There are many ways to obtain the user's IP on the net, rewrite the Postlogin method in the Auth controller, add the login record code (log on successfully, write the database record userid,ip,time and so on).
For remembering the account, need to do in the Auth middleware, but because many routes to do middleware, in the user page jump between easy to record duplication.
You can try to tree a flag in the session.

Log-in logs are not saved by yourself. Auth middleware can be broken

My project is not with the framework of the original login registration, as well as authorization, all written by myself, I was in the middleware call Operation Log event record

  • 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.