0

I am trying to set-up a system where 3rd party sites can interact with my Codeigniter site but I need a way of grabbing their domain. Here is a test I conducted to try and get it working.

I have this on a 3rd party site

    echo file_get_contents('http://mycodeigniterdomian.com/');

and on a fresh CI install (2.1.0) I have this in the welcome controller

public function index()
{
    //$this->load->view('welcome_message');

    $this->load->library('user_agent');

    echo 'Hello World';

    echo '<br><br> ------------------------------------------- <br><br>';

    echo $_SERVER['HTTP_REFERER'];

    echo '<br><br> ------------------------------------------- <br><br>';

    print_r($_SERVER);

    echo '<br><br> ------------------------------------------- <br><br>';

    print_r($this->input->server());

    echo '<br><br> ------------------------------------------- <br><br>';

    echo $this->agent->referrer();

}

But neither $_SERVER or agent->referrer() return anything.

I have also tried the code outside Codeigniter but on the same domain and HTTP_REFERER is working fine.

Any ideas?

1 Answer 1

0

The visitor of the page (page that call HTTP_REFERER) needs to be redirected from some other page (click from web page)

for example if you click on http://mycodeigniterdomian.com/, it will send

http://stackoverflow.com/questions/8823291/serverhttp-referer-not-working-using-codeigniter

to http://mycodeigniterdomian.com/

if it does not come from any page, no value is sent for HTTP_REFERER

2
  • Hi sorry I don't think I have explained it well. The first code snippet would be on a different page (eg mydomain.com/index.php) so if a user goes to that page then it should run the script and display the referer as mydomain.com/index.php. I can get this to work outside codeigniter no problem its just not working with it.
    – tag
    Jan 11, 2012 at 19:43
  • I've been using HTTP_REFERER in CodeIgniter for logging without any problem. This might be unrelated but have you check your .htaccess?
    – bbnn
    Jan 12, 2012 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.