Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.