Home | Reviews | GUIpedia | Forum | Fun500


tacodrake95I've got an idea
Hey Brandon, could you add something that shows who's online so that people can know who's on at the time?
2011-03-1910:42 PM

HorvatMRe:I\'ve got an idea
Seconded. Below the "New to the blog?" area would be a perfect place.
2011-03-205:14 AM

BrandonRe:I\'ve got an idea
Todd, how hard would that be for me to implement? What would I need to do code wise?
2011-03-208:42 AM

ToddRe:I\'ve got an idea
You'd need to do session tracking, basically when someone logs in, assign their login to a session ID (can be random). When they do something like reload a page, go to a forum topic, or just access the website, update the user's session ID to the current time. The chat room should look for people who were active within the recent 15 minutes or so (i.e. query the session table for recent activity and their users). Does this make sense or do you need more clarification?
2011-03-2010:17 AM

pharoahRe:I\'ve got an idea
Brandon, I'm betting that you already are using sessions, since it wouldn't keep me logged in if you weren't. The tough thing will be if you want the list to reflect who is active, rather than simply logged in. Maybe associate a value lastAction with each session in your database, and whenever that person loads a page, shove the valueof time() into there. Then you can sort by most recent lastAction times and pull up anyone who has been active in the last x minutes. Assuming you're using a database, that is. If you're not, well, almost everything will be a pain in the ass to implement.
2011-03-2011:05 AM

BrandonRe:I\'ve got an idea
I just use cookies :P No session stuff.
2011-03-207:15 PM

pharoahRe:I\'ve got an idea
Storing important information in cookies is called "trusting the client", and it's not secure (Brandon knows that now). Here's how to implement sessions. It's easy!
A bunch of PHP later, I think I've fixed it.
2011-03-207:42 PM

Other


2021 Brandon Cornell