Well you would probably need another db fields as a timedate

`logged_in` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

select id from table where username='blah'...