Home  >  Article  >  Backend Development  >  Why is $_SERVER[\'HTTP_REFERER\'] Empty in PHP?

Why is $_SERVER[\'HTTP_REFERER\'] Empty in PHP?

Barbara Streisand
Barbara StreisandOriginal
2024-10-31 19:21:29149browse

Why is $_SERVER['HTTP_REFERER'] Empty in PHP?

Getting Referrer URL in PHP

The Problem

When retrieving the referrer URL using $_SERVER['HTTP_REFERER'], it remains empty.

Identifying the Missing Variable

The prompt includes a snippet of $_SERVER, revealing that the missing variable is HTTP_REFERER.

Reasons for Empty $_SERVER['HTTP_REFERER']

  1. No Referrer: Users might navigate directly to the page without using a hyperlink or typing in the URL.
  2. Disconnected Users: Those submitting requests programmatically (e.g., with CURL) need not specify a referrer.

What to Consider

In the context of the provided $_SERVER output, the HTTP_REFERER variable is indeed missing. However, it's important to note that the omission of specific values has been censored for privacy purposes, and the actual output may differ.

The above is the detailed content of Why is $_SERVER[\'HTTP_REFERER\'] Empty in PHP?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn