Re: Users on line

From: Date: Sat, 04 Jan 2003 04:05:39 +0000
Subject: Re: Users on line
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-24541@lists.php.net to get a copy of this message
I had asked on -questions about something similar to this. My concern is how would a setup like this react to a dial up user that hops ip addresses (like AOL). Would the session id remain constant, over the ip hops?? Thanks Peter Beckman wrote:
Create a new table named online: id time (int unix timestamp) uid (int probably, user ID of user in question, relating to a user info table?) sessid (char 32 I think) When the user logs in, I assume you set the session. Insert a row with the current time (unix_timestamp(now()), User ID and the output of session_id() in PHP. This way you can run a query on that table at any time in one of two ways. 1. select count(id) from online where time>=(unix_timestamp(now())-900) This will give you the number of people who at least logged in in the last 15 minutes. This isn't very accurate though... so 2. If not already, put sessions in your SQL table. This way you can run a query like (and John Holmes, please feel free to clean up my joins, i suck at them): select count(*) from online,sessions where online.sessid=sessions.sessid and sessions.date>=(unix_timestamp(now())-900) This will give you the number of users who have done anything on the site in the last 15 minutes. Change the 900 to 600 or 300 for 10 or 5 minutes respectively. Every week or so you'll want to "delete from online where time>=[some number here, unix_timestamp(now()) minus how long you want to leave those entries there]". Depending on how often you want to do this and how busy your site is and how focused on performance you are, I'd advise running it once per minute and every time someone logs in, rather than once per page view, and put the values generated into a text file and read it in with readfile(). Peter On Fri, 3 Jan 2003, Bernain, Fernando G. wrote:
I'm working in an app that requires to know who are "on line". When the user login the app, I use session in order to storage de name and login. Its posible to do this??? Thanks! Fernando Bernain Senior A Business Process Outsourcing KPMG Argentina Tel: 54 11 4316 5754 Fax: 54 11 4316 5734 fbernain@kpmg.com.ar Email Disclaimer The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. When addressed to our clients any opinions or advice contained in this email are subject to the terms and conditions expressed in the governing KPMG client engagement letter. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
---------------------------------------------------------------------------
Peter Beckman                                                  Internet Guy
beckman@purplecow.com                             http://www.purplecow.com/
---------------------------------------------------------------------------
-- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/

« previous php.db (#24541) next »