php http referer не работает

$_SERVER[‘HTTP_REFERER’] missing

6 Answers 6

From the documentation:

The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

When a web browser moves from one website to another and between pages of a website, it can optionally pass the URL it came from. This is called the HTTP_REFERER, So if you don’t redirect from one page to another it might be missing

If the HTTP_REFERER has been set then it will be displayed. If it is not then you won’t see anything. If it’s not set and you have error reporting set to show notices, you’ll see an error like this instead:

To prevent this error when notices are on (I always develop with notices on), you can do this:

php http referer не работает. Смотреть фото php http referer не работает. Смотреть картинку php http referer не работает. Картинка про php http referer не работает. Фото php http referer не работает

Referer is not a compulsory header. It may or may not be there or could be modified/fictitious. Rely on it at your own risk. Anyways, you should wrap your call so you do not get an undefined index error:

If you don’t control the page, then there is nothing you can do.

php http referer не работает. Смотреть фото php http referer не работает. Смотреть картинку php http referer не работает. Картинка про php http referer не работает. Фото php http referer не работает

As stated by others very well, HTTP_REFERER is set by the local machine of the user, specifically the browser, which means it’s not reliable for security. However, this still is entirely the way in which Google Analytics monitors where you’re getting your visitors from, so, it can actually be useful to check, exclude, include, etc..

If you think you should see an HTTP_REFERER and do not, add this to your PHP code, preferably at the top:

A more appropriate long-term solution, of course, is to actually update your php.ini or equivalent file. This is a nice and quick way of verifying, though.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *