Prevent users from refreshing the page

Anyway, for me to work, so anyone who presses F5 or any refresh button will be moved to another page, instead of refreshing the page the user wants?

Sort of:

If (refresh){

  goto "link to hopme page"

}

If I’m not allowed to update information on a specific page at all?

I have people who just refresh non-stop, and that kills my bandwidth. This is a gaming site, so I do not want to ban ip.

+5
source share
11 answers
session_start();
if($_SESSION['hasbeenhere'] == 1)
{
 // Page refreshed
}
else
{
   $_SESSION['hasbeenhere'] = 1;
}

If a person does not have cookies allowed, this will fail. If someone goes to another page and returns, he will be shown as updated.

, , .

- , , F5 200 , .

$page = $_SERVER['REQUEST_URI'];
// Defaults
if(!isset($_SESSION[$page]['count']))
{
    $_SESSION[$page]['count'] = 1;
    $_SESSION[$page]['first_hit'] = time();
    $_SESSION[$page]['banned'] = false;
}
else
{
    $_SESSION[$page]['count']++; // Increase the counter
}

// If person is banned, end script
if($_SESSION[$page]['banned'] == true)
{
    die();
}

if($_SESSION[$page]['first_hit'] < time() - 30)
{
    $_SESSION[$page]['count'] = 1; // Reset every 30 seconds
}

if($_SESSION[$page]['count'] > 100)
{
    $_SESSION[$page]['banned'] = true; 
    // Ban if they hit over 100 times in 30 seconds.
}
+8

, . , .

+12

?

, , , .

+3

PHP- :

 if(isset($_SESSION["pagename-LAST_VIEWED"])) {
    v = $_SESSION["pagename-LAST_VIEWED"])
    if(time() - v < 15) {
       // user is refreshing more than once per 15 seconds
       // send them something else and die
       }
 }
 $_SESSION["pagename-LAST_VIEWED"] = time();

, crummy -PHP, .

(F5) , Enter .

- HTTP, , .

, : - , . , , AJAX, . Refresh , , .

+3

, , javascript, F5 , .

+1

, :

session_start();

if (isset($_SESSION['visited'])) {
    header("Location: http://the.page/you/want");
} else {
    $_SESSION['visited'] = true;
}
0

F5, . . , , . , cookie .

0

Javascript, , - , , , .. , - , JQuery, , , (, ).

0

, ( ). , , , , . , , . - , , (, AJAX). , , - F5, , .

0

, , , , ?

Cache-Control: public, max-age = 120 , 2 . control-f5 , ?

0

.

, $_POST , , $_SESSION var :

$_SESSION['admin']['PID']=session_id();
$_SESSION['admin']['user_user']=$_POST['user'];
$_SESSION['admin']['user_pass']=$_POST['pass'];
$_SESSION['admin']['last_access_time']=time();
if($_SERVER['REQUEST_METHOD']==="POST")
{
    header("LOCATION:".$_SERVER['PHP_SELF']."?p=redirected");
}

, , - , , , , .

PD:. "? p = " porpouse

0

All Articles