Get HTTP Referrer on Redirection

前端 未结 2 1078
庸人自扰
庸人自扰 2021-01-18 00:15

How can you get the HTTP Referrer when redirected from another website, not when they click on a link since it would work for $_SERVER[\'HTTP_REFERER\'], but it

2条回答
  •  -上瘾入骨i
    2021-01-18 01:06

    An example of how I did it. Say we have 3 pages, one calling the next.

    page1.com -> page2.com -> page3.com.
    

    in page2.com get the page1.com using:

    $referrer = $_SERVER['HTTP_REFERER'];//=page1.com
    

    when redirecting to page3, send $referrer as a GET parameter

    page3.com?referrer=$referrer
    

    in page3 read the $referrer from the get.

    $initialReferrer = $_GET['referrer'];//=page1.com
    

提交回复
热议问题