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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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