简体   繁体   中英

how to know from which URL the user has been redirected to a page in our site in php

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?!

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.

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"]; 
 ?>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM