문제

Can someone tell me that:

Can we get two step back referrer using php ? for example someone come though google.com to mysite.com and then he/she clicked on any other page of like mysite.com/page.php and on that page referrer should be google.com not mysite.com

possible ? Pleas help

도움이 되었습니까?

해결책

You can save it to cookie or session and use it on the next page.

if (!isset($_SESSION)) {
    session_start();
}
if (!isset($_SESSION['referrer'])) {
    $_SESSION['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'n/a';
}

// another page

$referer = isset($_SESSION['referrer']) ? $_SESSION['referrer'] : null;

다른 팁

The variable

$_SERVER['HTTP_REFERER']

CAN contain the referer, but it can only go one level deep, so you can see where the visitor came from, one step back, but not two steps.

use $_SERVER['HTTP_REFERER'] will get referrer if exists

I was looking to do the same thing a couple years ago. It is impossible to achieve it. If it is otherwise, i would be interested to know.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top