Setting max. pageviews per minute

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Terriator
Forum Commoner
Posts: 60
Joined: Mon Jul 04, 2005 12:46 pm

Setting max. pageviews per minute

Post by Terriator »

I need to limit the amount of pageview a user can have per minute to about 60.

How would I go about doing this? Of course I can make a mysql-solution, but I'm thinking there must be a way that takes less resources than that?

Thanks,
Terriator
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

keep a count in sessions maybe?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Or cookies (less reliable). Either way you'd have to have a database/storage solution and a user login, or this couldn't really be effective.

[edit] Oh, per minute. Sessions should do the trick.

Code: Select all

<?php
session_start();
if(!empty($_SESSION['pageviews']))
{
   $_SESSION['pageviews'] = $_SESSION['pageviews']+1;
} else
{
   $_SESSION['pageviews'] = 1;
}
?>
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Terriator
Forum Commoner
Posts: 60
Joined: Mon Jul 04, 2005 12:46 pm

Post by Terriator »

Yea, I already had that idea. Just wanted to be sure that there wasn't anything less resource taking =) .. I've got to the point where I my server-resources are running away from me =/
Post Reply