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