users online, sessions help
Moderator: General Moderators
-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm
users online, sessions help
So I have a site, and I would like to display current users online. The current way I am accomplishing this is, I have a database with a sessionid, time, ip fields. Now when a user enters the site, a session is started and the sessionid, time and ip is entered into the database. I run a query selecting rows within the last 15mins. Sessions are destroyed when the browser closes.
My dilemma is that when you enter the site, and then end the session. Then re-visit the site (creating a new session) it counts that as 2 different users thus faking the users online count. Now what i could do is if the users ip = ip in database update that row, but what if you have multiple computers shared one ip?
One way I can think of but don't know how to create the query is select rows within last 15mins but with different ips.
Any ideas? Thanks.
My dilemma is that when you enter the site, and then end the session. Then re-visit the site (creating a new session) it counts that as 2 different users thus faking the users online count. Now what i could do is if the users ip = ip in database update that row, but what if you have multiple computers shared one ip?
One way I can think of but don't know how to create the query is select rows within last 15mins but with different ips.
Any ideas? Thanks.
-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm
My site doesn't receive must activity so i kept it large. I rather not use AJAX when i know it can be done with PHP and MySQL.Burrito wrote:15 minutes is a large gap.
I'd suggest using ajax to fetch users who are online in a more realtime fashion. You can key it off of an ID on a row. It might show dupes, but if you lessen the time for a 'refresh' the dupes won't show as long.
-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
you've already pointed out that there's no way to uniquely identify users. You can't key it off of the ip address because multiple people could use the same IP. You don't want the same user shown twice and if they return within the 15 minute timeframe, they would.
the only solution I can see is to key it with the ip address in conjuction with the username (decreases the room for error, but error is still potentially there), or to use a cookie (which would be 100% (assuming the user can and will accept cookies)).
so in response to your last post, given the 'tools' you're using, it can't be done...you're gonna have to add more tools to your bag to accomplish what you're after.
the only solution I can see is to key it with the ip address in conjuction with the username (decreases the room for error, but error is still potentially there), or to use a cookie (which would be 100% (assuming the user can and will accept cookies)).
so in response to your last post, given the 'tools' you're using, it can't be done...you're gonna have to add more tools to your bag to accomplish what you're after.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA