That's kind of a toughie, since the whole HTTP "thang" is based on stateless scripting-- user requests a page, you process it, send back output, and the transaction is complete. There's no persistant connection between client and server.
But, there are some things you can do. But first, why in hell would your CMS be kicking people out after only 5 minutes' inactivity? That's silly. Unless you're moving large sums of money around, or work for the military or CIA, I see no reason for that level of security. Can you change that?
Anyway, you have a good thing going with that last_activity column in your table, but you have to make it a datetime or timestamp data type. The reason is so you can easily perform addition and subtraction on it using built-in MySQL functions. The one you'll find to be handy is timediff()
Using timediff, anytime you need to determine the amount of time it's been since a user did anything, you select the user info and calculate
. Along with that, you will of course need to update that database row every time someone does something. So basically every page in your system will need to call an update query on that column.