You can start with
PHP: MySQL Database[
^] and
PHP: MySQL Functions - Manual[
^]
Now, if you're handling the logins and logouts, then you already know how to do the above. If you're just creating webpages, you need to (1) learn SQL so you can (2) have a method of checking login credential; and you can easily record the login value then, if successful.
As for log-out, do you assume they'll use a logout button or something? If they did, you could use that to send an insert or update query to MySQL table. But, of course,they may just change the page or shut their browser. You can trap the first as, for example, an
unload [
^] event - but if they go to another page on your site, what do you do? You need to carry their logged-in state around with the pages (by session or in the URL). What if they leave your pages for another site and then reconnect?
You'll likely also want to learn
AJAX[
^]
With local applications, this wasn't so bad. With the internet, you've a lot to think about as you (server side) lose much (or all) control over the client side/state.