$_SERVER['HTTP_REFERER'] not working

I have the current set up of... a javascript file containing

$(document).ready(function() {
    cache: false,
    type: 'GET',
    url: './memberfunctions/getRef.php',
    data: {},
        // successful request; do something with the data
        // failed request; give feedback to user
        alert("idk what happened");

getRef.php is


$httpReferer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;

echo $httpReferer;


If i go to pastebin, type in and click mysite.com, i go to mysite.com and the console says mysite.com. Obviously I want the console to say pastebin.com/######

I know HTTP_REFERER is insecure, vulnerable, poor, unreliable. It serves a tiny non-vital purpose.



For your AJAX request, the referrer is not pastebin.com. Your parent page would have had the referrer set to pastebin.

You can try something like this as inline script:

<script> var ref = "<?php echo $_SERVER['HTTP_REFERER']; ?>"; </script>

OR below which need not be inline

<script> var ref = document.referrer; </script>

Unless am missing something in the intent of the AJAX call.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.