Jump to content

Logging IP's best method


acctman

Recommended Posts

I have two options, either

 

1. create a field (user_lastip) and just do a sql UPDATE everytime the user logs in.

or

2. separate table (site_logs) with user_id, user_name, user_lastip and timestamp. sql would have to do a lookup to see if they user_id exist in the "site_logs" table if not then INSERT, if it does then UPDATE.

 

Which method is better overall for performance on a large site?

Link to comment
https://forums.phpfreaks.com/topic/116503-logging-ips-best-method/
Share on other sites

If the relationship is 1:1 then I don't see any downside to just including a 'user_lastip' field in the users table.  There doesn't seem like any point in making a separate table when each user only needs 1 entry anyways - only do this if you want to record each ip from which a user connects because the relationship is then 1:many.

Yeah why have a 2nd table for this when its still only storiing one instance per user?

If you want a history of all logins then user a 2nd table, also you dont need to store the user name again, just the id which would link you ot the user table for their details.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.