Account nane
epiz_28268815
Error Message
$SERVER[‘HTTP_REFERER’] doesn’t exist
Other Information
I tried to access the superglobal variable $SERVER[‘HTTP_REFERER’], but it doesn’t seem to exist. In fact, by doing a var_dump of $SERVER, there is no key named HTTP_REFERER (which detects the page from which you are being redirected). How do I access this value
Sorry, I forgot to write the “_” here in the question, but I wrote it in my code
YT_Xaos
October 26, 2021, 11:25am
#4
In that case, could you please share your code?
1 Like
Sharing what you think is the code is not going to help us. Please copy and paste the actual code from your application here.
Thanks
3 Likes
This is the code that doesn’t work (it works only on localhost, but not on infinityfree host):
<?php
session_start();
if (str_contains($_SERVER['HTTP_REFERER'], 'some_text') || str_contains($_SERVER['HTTP_REFERER'], 'some_text')) {
echo "<a href=\"some_page.php\" class=\"go-back\" ><i class=\"fas fa-arrow-left\"></i>Some text</a>";
}
if (str_contains($_SERVER['HTTP_REFERER'], 'some_text')) {
echo "<a href=\"some_page\" class=\"go-back\"><i class=\"fas fa-arrow-left\"></i>Some text</a>";
}
?>
The problem is that $_SERVER[‘HTTP_REFERER’] doesn’t exist in $_SERVER.
Why?
YT_Xaos
October 26, 2021, 4:14pm
#7
In w3schools.com it says, “Returns the complete URL of the current page (not reliable because not all user-agents support it )”, might be that.
2 Likes
Do you know any other way to see which page you are being redirected from, accepted on infinityfree
YT_Xaos
October 26, 2021, 5:51pm
#9
Maybe $_SERVER[“REQUEST_URI”] or $_SERVER[“PHP_SELF”] in a session variable.
In HTTP, "Referer" (a misspelling of Referrer) is an optional HTTP header field that identifies the address of the web page (i.e., the URI or IRI), from which the resource has been requested. By checking the referrer, the server providing the new web page can see where the request originated.
In the most common situation, this means that when a user clicks a hyperlink in a web browser, causing the browser to send a request to the server holding the destination web page, the request may include t...
is the name of an optional HTTP…
optional
Since referer is optional, it must not be included in the request. That is most likely why you are not seeing it.
…
Also, fun fact: “referer” is misspelled and should be referer. If your inner English gets the better of you and writes “referrer”, while it is grammatically correct, the syntactically correct name is “referer”.
4 Likes
If you control the page redirecting itself, you can use POST or GET by sending the current URL to the page you are redirecting to.
Otherwise, if the page redirecting itself to you doesn’t provide information on itself, you will never know.
Privacy is a thing ya know
1 Like
system
Closed
November 2, 2021, 7:49pm
#14
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.