Hi;
I just did something like this myself a few days ago.
I created a table with 3 fields:
CREATE TABLE LOGRECORDS (\n LOGINID int(10) NOT NULL auto_increment COMMENT 'Primay key',\n USER varchar(25) NOT NULL,\n LOGGEDIN timestamp NOT NULL default CURRENT_TIMESTAMP,\n PRIMARY KEY (LOGINID)\n) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1
When the user logs in, the table gets a new record that includes the username and is automatically timestamped.
Then, I can query this table in any way I like to view the patterns of use.
ie.
SELECT DATE_FORMAT(LOGGEDIN,'%a, %m/%e/%Y') AS LOGDATE, USER, COUNT(LOGINID) AS LOGSTODAY FROM LOGRECORDS GROUP BY LOGDATE, USER ORDER BY LOGGEDIN, USER
This will give me a recordset that looks something like this:
LOGDATE USER LOGSTODAY
Thu, 06/11/2009 llikirjm 2
Thu, 06/11/2009 rhillivr 2
Thu, 06/11/2009 niilijy 1
Thu, 06/11/2009 hilin 2
Fri, 06/12/2009 lLIKiRJM 2
Fri, 06/12/2009 dukilk 4
Fri, 06/12/2009 hilminjl 1
Fri, 06/12/2009 kriulm 2
Fri, 06/12/2009 rriiwim1 3
Fri, 06/12/2009 kohnkidx 1
Fri, 06/12/2009 browndl1 1
The result of the query shows only one row for each user per day (since it is grouped on USER) but it preserves the information on how many times the user visited that day. Since the LOGGEDIN field is a complete date and time stamp, it could also be used for analysis of what times of day or days of the week or month your site is most used.