If later on you would like to use those IPs as for example in admin area of your blog, then IMHO it is better to store them in database. Later on you can cache them, but it is optional.
In WordPress (which is by the way very elastic blog system) database tables have wp_ prefix by default. So you could do something like that.
CREATE TABLE IF NOT EXISTS wp_ip_tracking (
id INT NOT NULL AUTO_INCREMENT,
ip VARCHAR(15) NOT NULL,
last_activity TIMESTAMP NOT NULL,
PRIMARY KEY(id),
UNIQUE(ip)
);
Then you could do some function which will be called, when member does pretty much anything. Depends on what you need.
function trackIP($ip) {
// Check if IP exists
$query1 = "SELECT id FROM wp_ip_tracking WHERE ip = '{$ip}'";
// Insert new record with given IP
$query2 = "INSERT INTO wp_ip_tracking(id, ip, last_activity) VALUES(NULL, '{$ip}', NOW())";
// Update record for specified IP
$query3 = "UPDATE wp_ip_tracking SET last_activity = NOW() WHERE ip = '{$ip}'";
if(mysql_num_rows(mysql_query($query1)) == 0) {
mysql_query($query2);
} else {
mysql_query($query3);
}
}
I think that those two should help you with your problem. Again it is only IMHO.