isedeasy Posted December 16, 2010 Share Posted December 16, 2010 I would like to add a feature to my site to show when a user was last active (exactally as you have here at PHP freaks). I would like to know the best way to go about this. The method I came up with would be to simply update a value in a column in the users table every time a page is loaded. Now obviously this would work but I can't see it being very efficient as I am basically doing an mysql update every time a page loads. What's the best way to go about this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/221875-last-active/ Share on other sites More sharing options...
shlumph Posted December 16, 2010 Share Posted December 16, 2010 I'm not sure how else you'd be able to do it accurately. You could just track their last login, but that's not as precise. Quote Link to comment https://forums.phpfreaks.com/topic/221875-last-active/#findComment-1148154 Share on other sites More sharing options...
isedeasy Posted December 16, 2010 Author Share Posted December 16, 2010 yeah last login will not be very good at all because of the remember me feature. The site uses memcache so maybe I could cache the last access time and run a cron job to delete the cache add update the database in the early morning? or does that sound like a stupid idea I don't want to decrease performance for a 'nice to have feature' but it would be nice to have that feature lol will running an update query every page load put much strain on the server? Quote Link to comment https://forums.phpfreaks.com/topic/221875-last-active/#findComment-1148201 Share on other sites More sharing options...
Philip Posted December 16, 2010 Share Posted December 16, 2010 will running an update query every page load put much strain on the server? As long as it is efficient, you won't have a problem. Hell, look at the bottom of these pages... "Page created in 0.03 seconds with 29 queries.". Granted, the MySQL server is its own, but still... Quote Link to comment https://forums.phpfreaks.com/topic/221875-last-active/#findComment-1148257 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.