TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-27-2008, 09:53 AM   #1 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default 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!
__________________
Tanax is offline  
Reply With Quote
Old 04-27-2008, 02:09 PM   #2 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 264
Thanks: 2
TlcAndres is on a distinguished road
Default

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
__________________
"What everyone seems to forget is that while knowledge certainly is something - it's the implementation of knowledge that brings power" - Andres Galindo.
TlcAndres is offline  
Reply With Quote
Old 04-27-2008, 02:28 PM   #3 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

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

Village Idiot is offline  
Reply With Quote
Old 04-27-2008, 04:25 PM   #4 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 264
Thanks: 2
TlcAndres is on a distinguished road
Default

You could just regenerate the cookie if it exists already.
__________________
"What everyone seems to forget is that while knowledge certainly is something - it's the implementation of knowledge that brings power" - Andres Galindo.
TlcAndres is offline  
Reply With Quote
Old 04-27-2008, 04:50 PM   #5 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by TlcAndres View Post
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 View Post
Not really, because it will recognize everyone as different whenever they log in again.
Didn't understand this.. :/
__________________
Tanax is offline  
Reply With Quote
Old 04-27-2008, 05:00 PM   #6 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 264
Thanks: 2
TlcAndres is on a distinguished road
Default

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.
__________________
"What everyone seems to forget is that while knowledge certainly is something - it's the implementation of knowledge that brings power" - Andres Galindo.
TlcAndres is offline  
Reply With Quote
The Following User Says Thank You to TlcAndres For This Useful Post:
Tanax (04-27-2008)
Old 04-27-2008, 07:05 PM   #7 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by TlcAndres View Post
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..
__________________
Tanax is offline  
Reply With Quote
Old 04-27-2008, 07:30 PM   #8 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 264
Thanks: 2
TlcAndres is on a distinguished road
Default

No, I meant the query to check if the ID has already been used.
__________________
"What everyone seems to forget is that while knowledge certainly is something - it's the implementation of knowledge that brings power" - Andres Galindo.
TlcAndres is offline  
Reply With Quote
Old 04-27-2008, 09:41 PM   #9 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by TlcAndres View Post
No, I meant the query to check if the ID has already been used.
But everyone can login on same user id.. ? :O
__________________
Tanax is offline  
Reply With Quote
Old 04-28-2008, 05:08 AM   #10 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Smile

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.
__________________
no signature set
sarmenhb is offline  
Reply With Quote
Old 04-28-2008, 09:33 AM   #11 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by sarmenhb View Post
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.
__________________
Tanax is offline  
Reply With Quote
Old 04-28-2008, 11:23 AM   #12 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

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?
Salathe is offline  
Reply With Quote
Old 04-28-2008, 03:28 PM   #13 (permalink)
The Wanderer
 
blayne4k's Avatar
 
Join Date: Apr 2008
Location: Trapped in my own little world.
Posts: 14
Thanks: 0
blayne4k is on a distinguished road
Default

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
blayne4k is offline  
Reply With Quote
Old 04-29-2008, 07:30 AM   #14 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

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 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..
__________________
Tanax is offline  
Reply With Quote
Old 04-29-2008, 02:50 PM   #15 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

I could just see your login page

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

Village Idiot is offline  
Reply With Quote
Old 04-29-2008, 03:17 PM   #16 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Excuse me? What? xD
__________________
Tanax is offline  
Reply With Quote
Old 04-29-2008, 04:32 PM   #17 (permalink)
Jay
The Contributor
Good Samaritan 
 
Join Date: Dec 2007
Posts: 60
Thanks: 5
Jay is on a distinguished road
Default

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
Jay is offline  
Reply With Quote
Old 04-30-2008, 08:57 PM   #18 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by Jay View Post
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
__________________
Tanax is offline  
Reply With Quote
Old 04-30-2008, 11:22 PM   #19 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Use .htpasswd to protect the site, and record ip/user agent combinations to determine who's online.
delayedinsanity is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:59 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design