Jump to content

Refering Url


dotkpay

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/242215-refering-url/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/242215-refering-url/#findComment-1243871
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/242215-refering-url/#findComment-1243914
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.