NYCPHP Meetup

NYPHP.org

[nycphp-talk] "how many users online" PHP solution: sessions or DB?

Nicholas Tang ntang at mail.communityconnect.com
Tue Nov 4 04:59:29 EST 2003


I might be missing something, but won't counting the session files only 
work if you have one webserver?  You can totally forget about 
scalability with that solution, and building crippled solutions always 
struck me as a bad way of doing things, as you'll just have to redo them 
in a few months anyways.

So my vote is definitely for a db-based solution.  Ours uses a db, and 
it works well.

Nicholas

Hans Zaunere wrote:

> 
> 
> Phil,
> 
> Phil Powell wrote:
> 
>> http://codewalkers.com/seecode/75.html
>> http://www.webkreator.com/php/concepts/counting-users-online-with-php.html 
>>
>>  
>> The following two URLs illustrate different approaches to the idea of 
>> showing "how many
>> users online" issue.  I am looking at two different sites where I am 
>> looking into implementing
>> this type of script; one that has mySQL and one that has no db access 
>> of any kind; both use
>> PHP 4.1.  
>> I (for once) understand what I would need to do to implement it; 
>> problem comes in as to which
>> solution would be the fastest, most efficient and most secure 
>> considering that one of them
>> deals with sessions (then there is the cookie issue, but that's 
>> another issue altogether,
>> see 
>> http://www.webkreator.com/php/configuration/php-session-security.html 
>> on security issues
>> and cookies/sessions).
>>  
>> What would one best recommend I use: the PHP/mySQL solution (for the 
>> non-db issue I would have
>> to write complicated XML procedures instead), or sessions?
> 
> 
> I think both links you mention are fairly good, and secure.  Using the 
> non-db solution (ie, it counts the number of session files in the tmp 
> directory) would probably be slower.  And, you'd have to take notice of 
> the expire time for the sessions; by default, the php sessions files 
> hang around for quite a while, and you'd be getting false counts.  If 
> possible, I'd go for the mysql method, but it obviously wouldn't work 
> for the non-db site, and it might not fit with the architecture of the 
> existing site.
> 
> Thanks,
> 
> Hans
> 
> 
> 
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk
> 





More information about the talk mailing list