0

I have written a webservice client connected to a bank address. After the user is being sent to the bank's website and completes the from, then automatically is being redirected to the page named callback.php

Now, I want to know that from which address the user is being redirected to callback page?! Is there a way to know it through PHP and of course if possible in codeigniter?!

Afshin
  • 2,427
  • 5
  • 36
  • 56
  • 1
    I believe you're looking for [referer](http://stackoverflow.com/questions/165975/determining-referer-in-php) – Andrei Jul 10 '15 at 11:16

3 Answers3

2

You should be able to access the referring location (if the user's browser has sent it, that is), with the following variable $_SERVER['HTTP_REFERER']

This should be accessible to you regardless of framework.

dsojevic
  • 1,066
  • 10
  • 11
1

There is no 100% way to solve this ...

You can try to use the Referer which was sent .. .but this result can be manipulatet or edited by user/browser etc...

<?php 
    $_referer = $_SERVER["HTTP_REFERER"]; 
 ?>
donald123
  • 5,638
  • 3
  • 26
  • 23
  • @AfshinHaghighat you can edit the "value" in browser or in request ... for example take a look at this firefox addon https://addons.mozilla.org/de/firefox/addon/refcontrol/ – donald123 Jul 10 '15 at 11:22
  • 1
    @AfshinHaghighat Values such as `HTTP_REFERER` and `HTTP_USER_AGENT` are sent from the user's browser (or program/script) connecting to your page. The program/script accessing your page can send any value they like for these (including blank values). – dsojevic Jul 10 '15 at 11:48
  • So, if that is unreliable, I have better not to use it. – Afshin Jul 10 '15 at 11:50
  • @AfshinHaghighat you can use it carefully ... but always keep in mind it can be empty, manipulatet or something else ... http protocol has no "minding" .... – donald123 Jul 10 '15 at 11:53
1

Codeigniter has it own user agent class

CI3 http://www.codeigniter.com/user_guide/libraries/user_agent.html

As per what user guide said.

if ($this->agent->is_referral())
{
   echo $this->agent->referrer();
}

CI2 http://www.codeigniter.com/userguide2/libraries/user_agent.html