I have a question from a potential client (hence, no code yet) about a website they have which has a custom login script.
Basically, they have Analytics setup but it doesn't serve the purpose that they need - being able to tell how many times a user has logged in and how frequently they do so.
What would be the best way of achieving this? I'm guessing I would need to alter the PHP login script but I'm a little confused at how best to do it. I could do a new field in the database that counts their logins but I suspect that that's not a great way of doing it, and I'm not sure how I could tell the frequency from that type of system.
Any suggestions?
Every time a user logs in you could log it in your db or to a file. You could easily include user name, datetime, ip, user agent (all relevant data) etc. As mentioned this will make it very easy to build a profile on the user, login times, login locations etc
If you store the time of each attempt, you can run reports to figure out whatever you need.
the best way to implement this is a relational database. When a user is logged in, an entry is made in a table. When you want to find out how many times a user has logged in, a query to this table to count the entries that apply to that user.
You can simply make a new table where you store user_id
and timestamp
everytime the user is logging in. Using that data you can then see who, how many times and in which intervals of the day has been logged in.