Limit number of visitors online

software development

#1

How would I go about limiting the number of visitors on a website? Like, say I want the maximum people online to be 10, and if a person enters the site while there are already ten other people viewing the site, he will be redirected to a temporary page until there is room for more visitors.

Does anyone have any information on how I would do this? Your help is greatly appreciated.


#2

A quick search of the wiki (wiki.dreamhost.com) turned up this page:

http://wiki.dreamhost.com/index.php/KB_/Unix/_.htaccess_files

On it is the entry that needs to be added to the .htaccess file that limits the number of users. Now, it’s important to note that I believe that an error message will be displayed when the “extra” person tries to connect. But you might be able to set things up specially.

Wholly


#3

If you are familiar with PHP, you can also create a couter. When the counter reaches certain number, direct the user to a temporary page.

I believe you can find codes of php counter in the internet.

To redirect, you can use PHP header. remember to put it before html header

Save [color=#CC0000]$97[/color] (max discount) on dreamhost by using promo code: [color=#CC0000]97CRAZY[/color].


#4

What kind of counter would this be? A counter that keeps track of visitors online or something like total/daily hits?


#5

Thank you. I didn’t think to check their Wiki. I was expecting something a bit more compliacted.


#6

If I understand you correctly, it will be something like today/daily hits.

It means the counter tracks how many users have come to your site today. Once it reaches the limit, redirect to the temp page

Save [color=#CC0000]$97[/color] (max discount) on dreamhost by using promo code: [color=#CC0000]97CRAZY[/color].


#7

I see. Well, what I’m looking is more of a way to prevent too many people being on the website at the same time.


#8

That’s what I thought you were looking for. That’s why I pointed you to the wiki as it references limiting “Concurrent” users.

Wholly


#9

What if someone wanted to limit a number of users to a page for a contest and once the tenth unique visitor has visited the page, the page gives them a thanks for playing message or redirects them to another.

Would anyone know how to do that?


#10

That would require some programming, such as PHP, and a way to store access counts (files or DB) or a way to parse the access logs (less reliable since they are only kept for a week).

It only takes a few lines of code to make a very simple counter. In fact, you could even modify one of the many examples of the rating scripts. You know the kind where someone clicks on the number of stars to rate something, and the script takes the value of the click, adds it to the previous clicks, and returns the average? Just change that to add a number each time a page is visited or vote is counted.