Traffic Script

They have: 50 posts

Joined: Aug 2001

I am looking for a script that says how many users are currently online, can someone help me out here?

`Bryan

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

We'll need to know what scripting language you're using...

They have: 50 posts

Joined: Aug 2001

Yes, sorry, I am using perl.

They have: 601 posts

Joined: Nov 2001

What exactly do you mean how many people are online? Are these people logged into a paticular system in anyway? Are you running a database with seshion cookies maybe?

Or are you simply just displaying a flat page and want to show who's online (without anyone logging in), therefore impossible?

Cheers

- wil

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

Its quite easy to do what you want in ASP, I'm not sure how to achieve this in perl though, sorry.

They have: 50 posts

Joined: Aug 2001

How can u do this in asp? What script would u use?

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

Add this to your Application_OnStart in global.asa

Application("CurrentUsers") = 0

Add this to your Session_OnStart in global.asa

Application.Lock
Application("CurrentUsers") = Application("CurrentUsers") + 1
Application.Unlock

Add this to your Session_OnEnd in global.asa

Application.Lock
Application("CurrentUsers") = Application("CurrentUsers") - 1
Application.Unlock

Then to display this on a page just put

<?php
=Application("CurrentUsers")
?>

PJ | Are we there yet?
pjboettcher.com

They have: 27 posts

Joined: Nov 2001

heres one to check out.

http://ss.animetrek.com/UzerzOnlyne.php

They have: 601 posts

Joined: Nov 2001

But how can you know who's online if you don't use some sort of seshions? No one is 'logged in' anywhere?

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

You don't really know who's online, only that there is someone online. It can be a little deceiving, for example, I could open 2 browser windows and browse the site, and it would say "2 users online" when there's really only one. It would be more accurate to say "2 current connections to the web service".

PJ | Are we there yet?
pjboettcher.com

They have: 601 posts

Joined: Nov 2001

Oh, right! That's simple enough! Sorry, I thought the user was asking how do I do a "Who's Online" script, like naming logged users such as the one on this front page (I think - haven't looked in a while). That would be impossible without some sort of seshions.

- wil

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.