TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Count multiple users on same account (http://www.talkphp.com/absolute-beginners/2714-count-multiple-users-same-account.html)

Tanax 04-27-2008 09:53 AM

Count multiple users on same account
 
Hi!

I have a website for the area where I live, and people don't have an own account, they use a single account.

So all of the people uses the same account.
How would I be able to record how many people are online on that account at the same time, and how many people that have been online at the same time at the most..

I'm open for pretty much any suggestion..
Thanks in advance!

TlcAndres 04-27-2008 02:09 PM

I'd give every single person who visits a unique cookie and when they login record it, then it's just a matter of

SELECT `unique_cookie_id` WHERE `u_id`=%d

Village Idiot 04-27-2008 02:28 PM

Not really, because it will recognize everyone as different whenever they log in again.

TlcAndres 04-27-2008 04:25 PM

You could just regenerate the cookie if it exists already.

Tanax 04-27-2008 04:50 PM

Quote:

Originally Posted by TlcAndres (Post 13991)
I'd give every single person who visits a unique cookie and when they login record it, then it's just a matter of

SELECT `unique_cookie_id` WHERE `u_id`=%d

That's kinda smart.. but set a cookie EVERY time they visit ?

Quote:

Originally Posted by Village Idiot (Post 13993)
Not really, because it will recognize everyone as different whenever they log in again.

Didn't understand this.. :/

TlcAndres 04-27-2008 05:00 PM

Not exactly, Village made a point from my lack of proper wording. Example:

PHP Code:


ob_start
();
if(!isset(
$_COOKIE['seperate'])){
  
$value md5(time());
  
//check if it's already in there...its unlike but I don't do chance
  
$query mysql_query($query)); //I assume you know how to do it.
  
$results = @reset(mysql_fetch_assoc($query));
  if(
$results == ''){
    
setcookie('seperate',$value,time() * 360000);
  }


Browsers expire cookies so I'd suggest regenerating the cookie on login along with recording it.

Tanax 04-27-2008 07:05 PM

Quote:

Originally Posted by TlcAndres (Post 13998)
Not exactly, Village made a point from my lack of proper wording. Example:

PHP Code:


ob_start
();
if(!isset(
$_COOKIE['seperate'])){
  
$value md5(time());
  
//check if it's already in there...its unlike but I don't do chance
  
$query mysql_query($query)); //I assume you know how to do it.
  
$results = @reset(mysql_fetch_assoc($query));
  if(
$results == ''){
    
setcookie('seperate',$value,time() * 360000);
  }


Browsers expire cookies so I'd suggest regenerating the cookie on login along with recording it.

Actually, I have never before in my life dealt with cookies.. :-/:-/

TlcAndres 04-27-2008 07:30 PM

No, I meant the query to check if the ID has already been used.

Tanax 04-27-2008 09:41 PM

Quote:

Originally Posted by TlcAndres (Post 14005)
No, I meant the query to check if the ID has already been used.

But everyone can login on same user id.. ? :O

sarmenhb 04-28-2008 05:08 AM

do this

add a new column to the userlogin table named ip
then

grab the users ip address who logs in and save it into the table.
then for every page visited if your using either cookies or sessions check to see if the userlogin that is being used matches the existing ip address in the database.

if the user decides to log out , still keep that ip address in the databse. when the user tries to re-login and his ip address is different than the one existing in the database, tell the user that they must change their password because they are logging in from a computer that wasnt used when the last user logged in.

so every time a user logs in and his ip doesnt match the one existing in the database they gotta change the password, this eventually gets on everyones last nerve and the users who dont have logins will eventually either quit or get their selves their own logins.

if you want the code on how to do all this, let me know i'll type it out.

Tanax 04-28-2008 09:33 AM

Quote:

Originally Posted by sarmenhb (Post 14029)
do this

add a new column to the userlogin table named ip
then

grab the users ip address who logs in and save it into the table.
then for every page visited if your using either cookies or sessions check to see if the userlogin that is being used matches the existing ip address in the database.

if the user decides to log out , still keep that ip address in the databse. when the user tries to re-login and his ip address is different than the one existing in the database, tell the user that they must change their password because they are logging in from a computer that wasnt used when the last user logged in.

so every time a user logs in and his ip doesnt match the one existing in the database they gotta change the password, this eventually gets on everyones last nerve and the users who dont have logins will eventually either quit or get their selves their own logins.

if you want the code on how to do all this, let me know i'll type it out.

But still, it's just one single user account in the database.
I want to record how many people are online on THAT SAME ACCOUNT at the SAME TIME.

Salathe 04-28-2008 11:23 AM

I might be asking a dumb question but why on earth would you allow many people to log in to your site using a shared user account in the first place?

blayne4k 04-28-2008 03:28 PM

Im wondering the same thing Salathe is...

Id simply make a table "loggedin" with coloums "username" "ip" "date"
when they login just add that there, you can make date the date and the hour or something, then just search for that username and the date your in

Example: date('d-m-Y-G')
blayne4k 127.0.0.1 04-28-08-10
blayne4k 127.0.0.2 04-28-08-10
blayne4k 127.0.0.1 04-28-08-11

select only the ones from that day and hour, and group by username, put a count on it and you can see how many people login that hour

Tanax 04-29-2008 07:30 AM

Because, this is not someplace where everyone will be able "register". This is a closed community just for the area where I live, it's like.. think of it as a guild :-P And most of the people who live here are like 60y.o and have barely knowledge of logging into the fking site xDD So that's why they have a shared user..

Village Idiot 04-29-2008 02:50 PM

I could just see your login page

Username:
Password:
Real Name (Yes, we know its not the maker):

Tanax 04-29-2008 03:17 PM

Excuse me? :-P What? xD

Jay 04-29-2008 04:32 PM

What's the point of having a user system for them then? Just make a guest-account system where they enter their "Guest Name" when they do things xD

Tanax 04-30-2008 08:57 PM

Quote:

Originally Posted by Jay (Post 14092)
What's the point of having a user system for them then? Just make a guest-account system where they enter their "Guest Name" when they do things xD

Well, I don't want anyone who visits the site to be able to see everything. That's why everyone in the society gets the account name and password so they can log in and view the site.

And I want to be able to record how many of them are online on that account at the same time :P

delayedinsanity 04-30-2008 11:22 PM

Use .htpasswd to protect the site, and record ip/user agent combinations to determine who's online.


All times are GMT. The time now is 12:39 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0