dotkpay Posted July 17, 2011 Share Posted July 17, 2011 Hello, Am trying to send the url of a certain file for example 'a.php' to be echoed in the present file 'c.php'. I understand a.php would be the referrer but php.net says $_SERVER['HTTP_REFERER'] is unreliable. Can someone please tell me how to use reliably. You could also show me a better means to display the refering url if there are any. Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/242215-refering-url/ Share on other sites More sharing options...
premiso Posted July 17, 2011 Share Posted July 17, 2011 If they are on the same server you will want to use sessions to pass variables around from page to page. a.php <?php session_start(); $_SESSION['var1'] = 'Test'; c.php <?php session_start(); echo isset($_SESSION['var1'])?$_SESSION['var1']:'Nothing was passed through session'; unset($_SESSION['var1']); // clears the variable. Quote Link to comment https://forums.phpfreaks.com/topic/242215-refering-url/#findComment-1243871 Share on other sites More sharing options...
dotkpay Posted July 17, 2011 Author Share Posted July 17, 2011 Ok, I just need to know how to use $_SERVER['HTTP_REFERER'] Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/242215-refering-url/#findComment-1243898 Share on other sites More sharing options...
premiso Posted July 17, 2011 Share Posted July 17, 2011 Ok, I just need to know how to use $_SERVER['HTTP_REFERER'] There is no better way, which is why I suggested sessions. Because the HTTP_REFERER can be changed by the user or turned off by the user, hence it is unreliable as it is controlled by the user. Unless you control the server or both servers, you cannot actively get the referring page. Quote Link to comment https://forums.phpfreaks.com/topic/242215-refering-url/#findComment-1243914 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.