You need two things:
1) When you login, you delete any existing login sessions for your name.
2) You create a script that executes on every page that checks for "idle" users. Any user over a specified time (10 minutes for example) is then automatically logged out.
For #2, when someone logs in, you log the date/time in their own "last activity" field. Every page the user accesses, their date/time activity is updated to the current time. Before updating the date/time activity field for the user, however, you check ALL USERS' date/time activity fields to see if their last activity is more than 10 minutes behind the current date/time. If it's been more than 10 minutes from the current time, you log them out.