I’m developing a user-system where I want to see if a user is online. I’ve considered making an extra column in my users table, with last_action. This would update every time a user looks at a page.
This would obviously require the MySQL database to update the user row every time a page is loaded. Would this be an optimal way of doing this?
You could solve that using cookies.
At your database, you already seem to have a
Time(or similar) field. Just do the same for a cookie. Then, you can compare the cookie’s time to the current one, and if the difference is large enough (e.g. 5, 10 minutes) you can edit it in the database as well.