1

Does anybody know how to detect in PHP if meta refresh was made to visit our page? I mean, some page have the following html code

<META HTTP-EQUIV='refresh' content='3; URL=http://www.example.com/mypage.php'> 

And I want to detect in mypage.php if it was realy that way of redirection.

P.S. website with meta refresh is not my website, so I cannot pass any parameters

P.P.S. I don't know exact URL of the website with meta refresh, it can be anything.

P.P.P.S. I am not interested in origin of redirection, I am interested in the FACT of that redirection.

ro_jero
  • 115
  • 10

1 Answers1

0

Just use sessions or cookies.

Check if it exists, elsewhere create it (to be detected on next refresh).

Some like:

session_start();
$currentPage = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
if (empty($_SESSION['lastSeenPage']) {
    if ($_SESSION['lastSeenPage'] == $currentPage) {
        // Comes from Refresh
    }
}
$_SESSION['lastSeenPage'] = $currentPage;

Maybe you need to check if that SESSION persists after visiting another pages. You can check it (where "//comes from Refresh") with

if($_SERVER["HTTP_REFERER"]== $currentPage) {
    // do the stuff
}
Carlos M. Meyer
  • 436
  • 3
  • 9