What you would be best doing is creating a new table to hold this data in your SQL something like "login_records" and every time you create a session for a member logging in you insert a new row.
So on your login page just before or just after you create the session/cookie simply just add in an addition like:
$user = $session[username]; // session users name
$date = date("d/m/Y"); // turns timestamp time into a read-able date
$time = date("g:i a", $dat); // turns timestamp time into a read-able time
$dat = time(); // Gets the current server time in a timestamp form
$insert = mysql_query("INSERT INTO `login_records`(id, username, date, time) VALUES ('', '$user', '$date', '$time')");
Your SQL table that holds these would require `id` to be the primary key with an auto increase. Then it is up to you what you are going to do with these rows :)
root = tkinter.Tk()
buttons=[i for i in range(10)]
#If specific button is pressed, output "YES"
for num in buttons: