$ _SERVER ['HTTP_REFERER'] does not show anything on my local server

0

I have this code and it shows nothing. I searched for information I did ANOTHER test with

<?php if(isset($_SERVER['HTTP_REFERER'])) {
    echo $_SERVER['HTTP_REFERER'];
    }

EITHER. I saw in a tutorial that a person if he left here, not me.

print_r($_SERVER)

What can I do since this will help me validate a method  mvc driverEjemp

  • if it comes from ajax
  • if it comes from the URL where the ajax function is
  • if token is valid
  • function validate () {

      if($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') { //Request identified as ajax request 
         if(@isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']=="http://mydomain/ajaxurl") { //HTTP_REFERER verifica
             if( isset($_POST['token']) && $_POST['token'] == $_SESSION['token']) { //verifiacion de token
                return true;
              } else { return false; } 
            } else { return false; } 
      } else { return false; } 
    
    }
    

    This I do to validate a method in mvc since I do not want a person to put the url and execute that function from the url. anque investigate that XMLHttpRequest does not work in all browsers.

        
    asked by Carlos 23.06.2018 в 19:26
    source

    0 answers